home *** CD-ROM | disk | FTP | other *** search
/ Risc World 7 / Risc World 7.iso / Software / Issue6 / SDL.ZIP / !gcc / docs / make < prev    next >
Text File  |  2006-09-17  |  484KB  |  10,825 lines

  1. This is /home/john/gccsdk/riscos/riscos-dist/!gcc/docs/make, produced
  2. by makeinfo version 4.8 from doc/make.texi.
  3.  
  4. INFO-DIR-SECTION GNU Packages
  5. START-INFO-DIR-ENTRY
  6. * Make: (make).            Remake files automatically.
  7. END-INFO-DIR-ENTRY
  8.  
  9.    This file documents the GNU Make utility, which determines
  10. automatically which pieces of a large program need to be recompiled,
  11. and issues the commands to recompile them.
  12.  
  13.    This is Edition 0.60, last updated 08 July 2002, of `The GNU Make
  14. Manual', for `make', Version 3.80.
  15.  
  16.    Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
  17. 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
  18.  
  19.    Permission is granted to copy, distribute and/or modify this document
  20. under the terms of the GNU Free Documentation License, Version 1.1 or
  21. any later version published by the Free Software Foundation; with no
  22. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  23. Texts.  A copy of the license is included in the section entitled "GNU
  24. Free Documentation License".
  25.  
  26. 
  27. File: make,  Node: Top,  Next: Overview,  Prev: (dir),  Up: (dir)
  28.  
  29. Make
  30. ****
  31.  
  32. The GNU `make' utility automatically determines which pieces of a large
  33. program need to be recompiled, and issues the commands to recompile
  34. them.
  35.  
  36.    This edition of the `GNU Make Manual', last updated 08 July 2002,
  37. documents GNU `make' Version 3.80.
  38.  
  39.    This manual describes `make' and contains the following chapters:
  40.  
  41. * Menu:
  42.  
  43. * Overview::                    Overview of `make'.
  44. * Introduction::                An introduction to `make'.
  45. * Makefiles::                   Makefiles tell `make' what to do.
  46. * Rules::                       Rules describe when a file must be remade.
  47. * Commands::                    Commands say how to remake a file.
  48. * Using Variables::             You can use variables to avoid repetition.
  49. * Conditionals::                Use or ignore parts of the makefile based
  50.                                   on the values of variables.
  51. * Functions::                   Many powerful ways to manipulate text.
  52. * Invoking make: Running.       How to invoke `make' on the command line.
  53. * Implicit Rules::              Use implicit rules to treat many files alike,
  54.                                   based on their file names.
  55. * Archives::                    How `make' can update library archives.
  56. * Features::                    Features GNU `make' has over other `make's.
  57. * Missing::                     What GNU `make' lacks from other `make's.
  58. * Makefile Conventions::        Conventions for writing makefiles for
  59.                                   GNU programs.
  60. * Quick Reference::             A quick reference for experienced users.
  61. * Error Messages::              A list of common errors generated by `make'.
  62. * Complex Makefile::            A real example of a straightforward,
  63.                                   but nontrivial, makefile.
  64.  
  65. * GNU Free Documentation License::  License for copying this manual
  66. * Concept Index::               Index of Concepts
  67. * Name Index::                  Index of Functions, Variables, & Directives
  68.  
  69.  --- The Detailed Node Listing ---
  70.  
  71. Overview of `make'
  72.  
  73. * Preparing::                   Preparing and Running Make
  74. * Reading::                     On Reading this Text
  75. * Bugs::                        Problems and Bugs
  76.  
  77. An Introduction to Makefiles
  78.  
  79. * Rule Introduction::           What a rule looks like.
  80. * Simple Makefile::             A Simple Makefile
  81. * How Make Works::              How `make' Processes This Makefile
  82. * Variables Simplify::          Variables Make Makefiles Simpler
  83. * make Deduces::                Letting `make' Deduce the Commands
  84. * Combine By Prerequisite::     Another Style of Makefile
  85. * Cleanup::                     Rules for Cleaning the Directory
  86.  
  87. Writing Makefiles
  88.  
  89. * Makefile Contents::           What makefiles contain.
  90. * Makefile Names::              How to name your makefile.
  91. * Include::                     How one makefile can use another makefile.
  92. * MAKEFILES Variable::          The environment can specify extra makefiles.
  93. * MAKEFILE_LIST Variable::      Discover which makefiles have been read.
  94. * Special Variables::           Other special variables.
  95. * Remaking Makefiles::          How makefiles get remade.
  96. * Overriding Makefiles::        How to override part of one makefile
  97.                                   with another makefile.
  98. * Reading Makefiles::           How makefiles are parsed.
  99.  
  100. Writing Rules
  101.  
  102. * Rule Example::                An example explained.
  103. * Rule Syntax::                 General syntax explained.
  104. * Prerequisite Types::          There are two types of prerequisites.
  105. * Wildcards::                   Using wildcard characters such as `*'.
  106. * Directory Search::            Searching other directories for source files.
  107. * Phony Targets::               Using a target that is not a real file's name.
  108. * Force Targets::               You can use a target without commands
  109.                                   or prerequisites to mark other
  110.                                   targets as phony.
  111. * Empty Targets::               When only the date matters and the
  112.                                   files are empty.
  113. * Special Targets::             Targets with special built-in meanings.
  114. * Multiple Targets::            When to make use of several targets in a rule.
  115. * Multiple Rules::              How to use several rules with the same target.
  116. * Static Pattern::              Static pattern rules apply to multiple targets
  117.                                   and can vary the prerequisites according to
  118.                                   the target name.
  119. * Double-Colon::                How to use a special kind of rule to allow
  120.                                   several independent rules for one target.
  121. * Automatic Prerequisites::     How to automatically generate rules giving
  122.                                   prerequisites from source files themselves.
  123.  
  124. Using Wildcard Characters in File Names
  125.  
  126. * Wildcard Examples::           Several examples
  127. * Wildcard Pitfall::            Problems to avoid.
  128. * Wildcard Function::           How to cause wildcard expansion where
  129.                                   it does not normally take place.
  130.  
  131. Searching Directories for Prerequisites
  132.  
  133. * General Search::              Specifying a search path that applies
  134.                                   to every prerequisite.
  135. * Selective Search::            Specifying a search path
  136.                                   for a specified class of names.
  137. * Search Algorithm::            When and how search paths are applied.
  138. * Commands/Search::             How to write shell commands that work together
  139.                                   with search paths.
  140. * Implicit/Search::             How search paths affect implicit rules.
  141. * Libraries/Search::            Directory search for link libraries.
  142.  
  143. Static Pattern Rules
  144.  
  145. * Static Usage::                The syntax of static pattern rules.
  146. * Static versus Implicit::      When are they better than implicit rules?
  147.  
  148. Writing the Commands in Rules
  149.  
  150. * Echoing::                     How to control when commands are echoed.
  151. * Execution::                   How commands are executed.
  152. * Parallel::                    How commands can be executed in parallel.
  153. * Errors::                      What happens after a command execution error.
  154. * Interrupts::                  What happens when a command is interrupted.
  155. * Recursion::                   Invoking `make' from makefiles.
  156. * Sequences::                   Defining canned sequences of commands.
  157. * Empty Commands::              Defining useful, do-nothing commands.
  158.  
  159. Recursive Use of `make'
  160.  
  161. * MAKE Variable::               The special effects of using `$(MAKE)'.
  162. * Variables/Recursion::         How to communicate variables to a sub-`make'.
  163. * Options/Recursion::           How to communicate options to a sub-`make'.
  164. * -w Option::                   How the `-w' or `--print-directory' option
  165.                                   helps debug use of recursive `make' commands.
  166.  
  167. How to Use Variables
  168.  
  169. * Reference::                   How to use the value of a variable.
  170. * Flavors::                     Variables come in two flavors.
  171. * Advanced::                    Advanced features for referencing a variable.
  172. * Values::                      All the ways variables get their values.
  173. * Setting::                     How to set a variable in the makefile.
  174. * Appending::                   How to append more text to the old value
  175.                                   of a variable.
  176. * Override Directive::          How to set a variable in the makefile even if
  177.                                   the user has set it with a command argument.
  178. * Defining::                    An alternate way to set a variable
  179.                                   to a verbatim string.
  180. * Environment::                 Variable values can come from the environment.
  181. * Target-specific::             Variable values can be defined on a per-target
  182.                                   basis.
  183. * Pattern-specific::            Target-specific variable values can be applied
  184.                                   to a group of targets that match a pattern.
  185.  
  186. Advanced Features for Reference to Variables
  187.  
  188. * Substitution Refs::           Referencing a variable with
  189.                                   substitutions on the value.
  190. * Computed Names::              Computing the name of the variable to refer to.
  191.  
  192. Conditional Parts of Makefiles
  193.  
  194. * Conditional Example::         Example of a conditional
  195. * Conditional Syntax::          The syntax of conditionals.
  196. * Testing Flags::               Conditionals that test flags.
  197.  
  198. Functions for Transforming Text
  199.  
  200. * Syntax of Functions::         How to write a function call.
  201. * Text Functions::              General-purpose text manipulation functions.
  202. * File Name Functions::         Functions for manipulating file names.
  203. * Foreach Function::            Repeat some text with controlled variation.
  204. * If Function::                 Conditionally expand a value.
  205. * Call Function::               Expand a user-defined function.
  206. * Value Function::              Return the un-expanded value of a variable.
  207. * Eval Function::               Evaluate the arguments as makefile syntax.
  208. * Origin Function::             Find where a variable got its value.
  209. * Shell Function::              Substitute the output of a shell command.
  210. * Make Control Functions::      Functions that control how make runs.
  211.  
  212. How to Run `make'
  213.  
  214. * Makefile Arguments::          How to specify which makefile to use.
  215. * Goals::                       How to use goal arguments to specify which
  216.                                   parts of the makefile to use.
  217. * Instead of Execution::        How to use mode flags to specify what
  218.                                   kind of thing to do with the commands
  219.                                   in the makefile other than simply
  220.                                   execute them.
  221. * Avoiding Compilation::        How to avoid recompiling certain files.
  222. * Overriding::                  How to override a variable to specify
  223.                                   an alternate compiler and other things.
  224. * Testing::                     How to proceed past some errors, to
  225.                                   test compilation.
  226. * Options Summary::             Summary of Options
  227.  
  228. Using Implicit Rules
  229.  
  230. * Using Implicit::              How to use an existing implicit rule
  231.                                   to get the commands for updating a file.
  232. * Catalogue of Rules::          A list of built-in implicit rules.
  233. * Implicit Variables::          How to change what predefined rules do.
  234. * Chained Rules::               How to use a chain of implicit rules.
  235. * Pattern Rules::               How to define new implicit rules.
  236. * Last Resort::                 How to defining commands for rules
  237.                                   which cannot find any.
  238. * Suffix Rules::                The old-fashioned style of implicit rule.
  239. * Implicit Rule Search::        The precise algorithm for applying
  240.                                   implicit rules.
  241.  
  242. Defining and Redefining Pattern Rules
  243.  
  244. * Pattern Intro::               An introduction to pattern rules.
  245. * Pattern Examples::            Examples of pattern rules.
  246. * Automatic::                   How to use automatic variables in the
  247.                                   commands of implicit rules.
  248. * Pattern Match::               How patterns match.
  249. * Match-Anything Rules::        Precautions you should take prior to
  250.                                   defining rules that can match any
  251.                                   target file whatever.
  252. * Canceling Rules::             How to override or cancel built-in rules.
  253.  
  254. Using `make' to Update Archive Files
  255.  
  256. * Archive Members::             Archive members as targets.
  257. * Archive Update::              The implicit rule for archive member targets.
  258. * Archive Pitfalls::            Dangers to watch out for when using archives.
  259. * Archive Suffix Rules::        You can write a special kind of suffix rule
  260.                                   for updating archives.
  261.  
  262. Implicit Rule for Archive Member Targets
  263.  
  264. * Archive Symbols::             How to update archive symbol directories.
  265.  
  266. Makefile Conventions
  267.  
  268. * Makefile Basics::             General Conventions for Makefiles
  269. * Utilities in Makefiles::      Utilities in Makefiles
  270. * Command Variables::           Variables for Specifying Commands
  271. * Directory Variables::         Variables for Installation Directories
  272. * Standard Targets::            Standard Targets for Users
  273. * Install Command Categories::  Three categories of commands in the `install'
  274.  
  275. Copying This Manual
  276.  
  277. 
  278. File: make,  Node: Overview,  Next: Introduction,  Prev: Top,  Up: Top
  279.  
  280. 1 Overview of `make'
  281. ********************
  282.  
  283. The `make' utility automatically determines which pieces of a large
  284. program need to be recompiled, and issues commands to recompile them.
  285. This manual describes GNU `make', which was implemented by Richard
  286. Stallman and Roland McGrath.  Development since Version 3.76 has been
  287. handled by Paul Smith.
  288.  
  289.    GNU `make' conforms to section 6.2 of `IEEE Standard 1003.2-1992'
  290. (POSIX.2).  
  291.  
  292.    Our examples show C programs, since they are most common, but you
  293. can use `make' with any programming language whose compiler can be run
  294. with a shell command.  Indeed, `make' is not limited to programs.  You
  295. can use it to describe any task where some files must be updated
  296. automatically from others whenever the others change.
  297.  
  298. * Menu:
  299.  
  300. * Preparing::                   Preparing and Running Make
  301. * Reading::                     On Reading this Text
  302. * Bugs::                        Problems and Bugs
  303.  
  304. 
  305. File: make,  Node: Preparing,  Next: Reading,  Prev: Overview,  Up: Overview
  306.  
  307. Preparing and Running Make
  308. ==========================
  309.  
  310.    To prepare to use `make', you must write a file called the
  311. "makefile" that describes the relationships among files in your program
  312. and provides commands for updating each file.  In a program, typically,
  313. the executable file is updated from object files, which are in turn
  314. made by compiling source files.
  315.  
  316.    Once a suitable makefile exists, each time you change some source
  317. files, this simple shell command:
  318.  
  319.      make
  320.  
  321. suffices to perform all necessary recompilations.  The `make' program
  322. uses the makefile data base and the last-modification times of the
  323. files to decide which of the files need to be updated.  For each of
  324. those files, it issues the commands recorded in the data base.
  325.  
  326.    You can provide command line arguments to `make' to control which
  327. files should be recompiled, or how.  *Note How to Run `make': Running.
  328.  
  329. 
  330. File: make,  Node: Reading,  Next: Bugs,  Prev: Preparing,  Up: Overview
  331.  
  332. 1.1 How to Read This Manual
  333. ===========================
  334.  
  335. If you are new to `make', or are looking for a general introduction,
  336. read the first few sections of each chapter, skipping the later
  337. sections.  In each chapter, the first few sections contain introductory
  338. or general information and the later sections contain specialized or
  339. technical information.  The exception is the second chapter, *Note An
  340. Introduction to Makefiles: Introduction, all of which is introductory.
  341.  
  342.    If you are familiar with other `make' programs, see *Note Features
  343. of GNU `make': Features, which lists the enhancements GNU `make' has,
  344. and *Note Incompatibilities and Missing Features: Missing, which
  345. explains the few things GNU `make' lacks that others have.
  346.  
  347.    For a quick summary, see *Note Options Summary::, *Note Quick
  348. Reference::, and *Note Special Targets::.
  349.  
  350. 
  351. File: make,  Node: Bugs,  Prev: Reading,  Up: Overview
  352.  
  353. 1.2 Problems and Bugs
  354. =====================
  355.  
  356. If you have problems with GNU `make' or think you've found a bug,
  357. please report it to the developers; we cannot promise to do anything but
  358. we might well want to fix it.
  359.  
  360.    Before reporting a bug, make sure you've actually found a real bug.
  361. Carefully reread the documentation and see if it really says you can do
  362. what you're trying to do.  If it's not clear whether you should be able
  363. to do something or not, report that too; it's a bug in the
  364. documentation!
  365.  
  366.    Before reporting a bug or trying to fix it yourself, try to isolate
  367. it to the smallest possible makefile that reproduces the problem.  Then
  368. send us the makefile and the exact results `make' gave you, including
  369. any error or warning messages.  Please don't paraphrase these messages:
  370. it's best to cut and paste them into your report.  When generating this
  371. small makefile, be sure to not use any non-free or unusual tools in
  372. your commands: you can almost always emulate what such a tool would do
  373. with simple shell commands.  Finally, be sure to explain what you
  374. expected to occur; this will help us decide whether the problem was
  375. really in the documentation.
  376.  
  377.    Once you have a precise problem you can report it in one of two ways.
  378. Either send electronic mail to:
  379.  
  380.          bug-make@gnu.org
  381.  
  382. or use our Web-based project management tool, at:
  383.  
  384.          http://savannah.gnu.org/projects/make/
  385.  
  386. In addition to the information above, please be careful to include the
  387. version number of `make' you are using.  You can get this information
  388. with the command `make --version'.  Be sure also to include the type of
  389. machine and operating system you are using.  One way to obtain this
  390. information is by looking at the final lines of output from the command
  391. `make --help'.
  392.  
  393. 
  394. File: make,  Node: Introduction,  Next: Makefiles,  Prev: Overview,  Up: Top
  395.  
  396. 2 An Introduction to Makefiles
  397. ******************************
  398.  
  399. You need a file called a "makefile" to tell `make' what to do.  Most
  400. often, the makefile tells `make' how to compile and link a program.  
  401.  
  402.    In this chapter, we will discuss a simple makefile that describes
  403. how to compile and link a text editor which consists of eight C source
  404. files and three header files.  The makefile can also tell `make' how to
  405. run miscellaneous commands when explicitly asked (for example, to remove
  406. certain files as a clean-up operation).  To see a more complex example
  407. of a makefile, see *Note Complex Makefile::.
  408.  
  409.    When `make' recompiles the editor, each changed C source file must
  410. be recompiled.  If a header file has changed, each C source file that
  411. includes the header file must be recompiled to be safe.  Each
  412. compilation produces an object file corresponding to the source file.
  413. Finally, if any source file has been recompiled, all the object files,
  414. whether newly made or saved from previous compilations, must be linked
  415. together to produce the new executable editor.  
  416.  
  417. * Menu:
  418.  
  419. * Rule Introduction::           What a rule looks like.
  420. * Simple Makefile::             A Simple Makefile
  421. * How Make Works::              How `make' Processes This Makefile
  422. * Variables Simplify::          Variables Make Makefiles Simpler
  423. * make Deduces::                Letting `make' Deduce the Commands
  424. * Combine By Prerequisite::     Another Style of Makefile
  425. * Cleanup::                     Rules for Cleaning the Directory
  426.  
  427. 
  428. File: make,  Node: Rule Introduction,  Next: Simple Makefile,  Prev: Introduction,  Up: Introduction
  429.  
  430. 2.1 What a Rule Looks Like
  431. ==========================
  432.  
  433. A simple makefile consists of "rules" with the following shape:
  434.  
  435.      TARGET ... : PREREQUISITES ...
  436.              COMMAND
  437.              ...
  438.              ...
  439.  
  440.    A "target" is usually the name of a file that is generated by a
  441. program; examples of targets are executable or object files.  A target
  442. can also be the name of an action to carry out, such as `clean' (*note
  443. Phony Targets::).
  444.  
  445.    A "prerequisite" is a file that is used as input to create the
  446. target.  A target often depends on several files.
  447.  
  448.    A "command" is an action that `make' carries out.  A rule may have
  449. more than one command, each on its own line.  *Please note:* you need
  450. to put a tab character at the beginning of every command line!  This is
  451. an obscurity that catches the unwary.
  452.  
  453.    Usually a command is in a rule with prerequisites and serves to
  454. create a target file if any of the prerequisites change.  However, the
  455. rule that specifies commands for the target need not have
  456. prerequisites.  For example, the rule containing the delete command
  457. associated with the target `clean' does not have prerequisites.
  458.  
  459.    A "rule", then, explains how and when to remake certain files which
  460. are the targets of the particular rule.  `make' carries out the
  461. commands on the prerequisites to create or update the target.  A rule
  462. can also explain how and when to carry out an action.  *Note Writing
  463. Rules: Rules.
  464.  
  465.    A makefile may contain other text besides rules, but a simple
  466. makefile need only contain rules.  Rules may look somewhat more
  467. complicated than shown in this template, but all fit the pattern more
  468. or less.
  469.  
  470. 
  471. File: make,  Node: Simple Makefile,  Next: How Make Works,  Prev: Rule Introduction,  Up: Introduction
  472.  
  473. 2.2 A Simple Makefile
  474. =====================
  475.  
  476. Here is a straightforward makefile that describes the way an executable
  477. file called `edit' depends on eight object files which, in turn, depend
  478. on eight C source and three header files.
  479.  
  480.    In this example, all the C files include `defs.h', but only those
  481. defining editing commands include `command.h', and only low level files
  482. that change the editor buffer include `buffer.h'.
  483.  
  484.      edit : main.o kbd.o command.o display.o \
  485.             insert.o search.o files.o utils.o
  486.              cc -o edit main.o kbd.o command.o display.o \
  487.                         insert.o search.o files.o utils.o
  488.  
  489.      main.o : main.c defs.h
  490.              cc -c main.c
  491.      kbd.o : kbd.c defs.h command.h
  492.              cc -c kbd.c
  493.      command.o : command.c defs.h command.h
  494.              cc -c command.c
  495.      display.o : display.c defs.h buffer.h
  496.              cc -c display.c
  497.      insert.o : insert.c defs.h buffer.h
  498.              cc -c insert.c
  499.      search.o : search.c defs.h buffer.h
  500.              cc -c search.c
  501.      files.o : files.c defs.h buffer.h command.h
  502.              cc -c files.c
  503.      utils.o : utils.c defs.h
  504.              cc -c utils.c
  505.      clean :
  506.              rm edit main.o kbd.o command.o display.o \
  507.                 insert.o search.o files.o utils.o
  508.  
  509. We split each long line into two lines using backslash-newline; this is
  510. like using one long line, but is easier to read.  
  511.  
  512.    To use this makefile to create the executable file called `edit',
  513. type:
  514.  
  515.      make
  516.  
  517.    To use this makefile to delete the executable file and all the object
  518. files from the directory, type:
  519.  
  520.      make clean
  521.  
  522.    In the example makefile, the targets include the executable file
  523. `edit', and the object files `main.o' and `kbd.o'.  The prerequisites
  524. are files such as `main.c' and `defs.h'.  In fact, each `.o' file is
  525. both a target and a prerequisite.  Commands include `cc -c main.c' and
  526. `cc -c kbd.c'.
  527.  
  528.    When a target is a file, it needs to be recompiled or relinked if any
  529. of its prerequisites change.  In addition, any prerequisites that are
  530. themselves automatically generated should be updated first.  In this
  531. example, `edit' depends on each of the eight object files; the object
  532. file `main.o' depends on the source file `main.c' and on the header
  533. file `defs.h'.
  534.  
  535.    A shell command follows each line that contains a target and
  536. prerequisites.  These shell commands say how to update the target file.
  537. A tab character must come at the beginning of every command line to
  538. distinguish commands lines from other lines in the makefile.  (Bear in
  539. mind that `make' does not know anything about how the commands work.
  540. It is up to you to supply commands that will update the target file
  541. properly.  All `make' does is execute the commands in the rule you have
  542. specified when the target file needs to be updated.)  
  543.  
  544.    The target `clean' is not a file, but merely the name of an action.
  545. Since you normally do not want to carry out the actions in this rule,
  546. `clean' is not a prerequisite of any other rule.  Consequently, `make'
  547. never does anything with it unless you tell it specifically.  Note that
  548. this rule not only is not a prerequisite, it also does not have any
  549. prerequisites, so the only purpose of the rule is to run the specified
  550. commands.  Targets that do not refer to files but are just actions are
  551. called "phony targets".  *Note Phony Targets::, for information about
  552. this kind of target.  *Note Errors in Commands: Errors, to see how to
  553. cause `make' to ignore errors from `rm' or any other command.  
  554.  
  555. 
  556. File: make,  Node: How Make Works,  Next: Variables Simplify,  Prev: Simple Makefile,  Up: Introduction
  557.  
  558. 2.3 How `make' Processes a Makefile
  559. ===================================
  560.  
  561. By default, `make' starts with the first target (not targets whose
  562. names start with `.').  This is called the "default goal".  ("Goals"
  563. are the targets that `make' strives ultimately to update.  *Note
  564. Arguments to Specify the Goals: Goals.)  
  565.  
  566.    In the simple example of the previous section, the default goal is to
  567. update the executable program `edit'; therefore, we put that rule first.
  568.  
  569.    Thus, when you give the command:
  570.  
  571.      make
  572.  
  573. `make' reads the makefile in the current directory and begins by
  574. processing the first rule.  In the example, this rule is for relinking
  575. `edit'; but before `make' can fully process this rule, it must process
  576. the rules for the files that `edit' depends on, which in this case are
  577. the object files.  Each of these files is processed according to its
  578. own rule.  These rules say to update each `.o' file by compiling its
  579. source file.  The recompilation must be done if the source file, or any
  580. of the header files named as prerequisites, is more recent than the
  581. object file, or if the object file does not exist.
  582.  
  583.    The other rules are processed because their targets appear as
  584. prerequisites of the goal.  If some other rule is not depended on by the
  585. goal (or anything it depends on, etc.), that rule is not processed,
  586. unless you tell `make' to do so (with a command such as `make clean').
  587.  
  588.    Before recompiling an object file, `make' considers updating its
  589. prerequisites, the source file and header files.  This makefile does not
  590. specify anything to be done for them--the `.c' and `.h' files are not
  591. the targets of any rules--so `make' does nothing for these files.  But
  592. `make' would update automatically generated C programs, such as those
  593. made by Bison or Yacc, by their own rules at this time.
  594.  
  595.    After recompiling whichever object files need it, `make' decides
  596. whether to relink `edit'.  This must be done if the file `edit' does
  597. not exist, or if any of the object files are newer than it.  If an
  598. object file was just recompiled, it is now newer than `edit', so `edit'
  599. is relinked.  
  600.  
  601.    Thus, if we change the file `insert.c' and run `make', `make' will
  602. compile that file to update `insert.o', and then link `edit'.  If we
  603. change the file `command.h' and run `make', `make' will recompile the
  604. object files `kbd.o', `command.o' and `files.o' and then link the file
  605. `edit'.
  606.  
  607. 
  608. File: make,  Node: Variables Simplify,  Next: make Deduces,  Prev: How Make Works,  Up: Introduction
  609.  
  610. 2.4 Variables Make Makefiles Simpler
  611. ====================================
  612.  
  613. In our example, we had to list all the object files twice in the rule
  614. for `edit' (repeated here):
  615.  
  616.      edit : main.o kbd.o command.o display.o \
  617.                    insert.o search.o files.o utils.o
  618.              cc -o edit main.o kbd.o command.o display.o \
  619.                         insert.o search.o files.o utils.o
  620.  
  621.    Such duplication is error-prone; if a new object file is added to the
  622. system, we might add it to one list and forget the other.  We can
  623. eliminate the risk and simplify the makefile by using a variable.
  624. "Variables" allow a text string to be defined once and substituted in
  625. multiple places later (*note How to Use Variables: Using Variables.).
  626.  
  627.    It is standard practice for every makefile to have a variable named
  628. `objects', `OBJECTS', `objs', `OBJS', `obj', or `OBJ' which is a list
  629. of all object file names.  We would define such a variable `objects'
  630. with a line like this in the makefile:
  631.  
  632.      objects = main.o kbd.o command.o display.o \
  633.                insert.o search.o files.o utils.o
  634.  
  635. Then, each place we want to put a list of the object file names, we can
  636. substitute the variable's value by writing `$(objects)' (*note How to
  637. Use Variables: Using Variables.).
  638.  
  639.    Here is how the complete simple makefile looks when you use a
  640. variable for the object files:
  641.  
  642.      objects = main.o kbd.o command.o display.o \
  643.                insert.o search.o files.o utils.o
  644.  
  645.      edit : $(objects)
  646.              cc -o edit $(objects)
  647.      main.o : main.c defs.h
  648.              cc -c main.c
  649.      kbd.o : kbd.c defs.h command.h
  650.              cc -c kbd.c
  651.      command.o : command.c defs.h command.h
  652.              cc -c command.c
  653.      display.o : display.c defs.h buffer.h
  654.              cc -c display.c
  655.      insert.o : insert.c defs.h buffer.h
  656.              cc -c insert.c
  657.      search.o : search.c defs.h buffer.h
  658.              cc -c search.c
  659.      files.o : files.c defs.h buffer.h command.h
  660.              cc -c files.c
  661.      utils.o : utils.c defs.h
  662.              cc -c utils.c
  663.      clean :
  664.              rm edit $(objects)
  665.  
  666. 
  667. File: make,  Node: make Deduces,  Next: Combine By Prerequisite,  Prev: Variables Simplify,  Up: Introduction
  668.  
  669. 2.5 Letting `make' Deduce the Commands
  670. ======================================
  671.  
  672. It is not necessary to spell out the commands for compiling the
  673. individual C source files, because `make' can figure them out: it has an
  674. "implicit rule" for updating a `.o' file from a correspondingly named
  675. `.c' file using a `cc -c' command.  For example, it will use the
  676. command `cc -c main.c -o main.o' to compile `main.c' into `main.o'.  We
  677. can therefore omit the commands from the rules for the object files.
  678. *Note Using Implicit Rules: Implicit Rules.
  679.  
  680.    When a `.c' file is used automatically in this way, it is also
  681. automatically added to the list of prerequisites.  We can therefore omit
  682. the `.c' files from the prerequisites, provided we omit the commands.
  683.  
  684.    Here is the entire example, with both of these changes, and a
  685. variable `objects' as suggested above:
  686.  
  687.      objects = main.o kbd.o command.o display.o \
  688.                insert.o search.o files.o utils.o
  689.  
  690.      edit : $(objects)
  691.              cc -o edit $(objects)
  692.  
  693.      main.o : defs.h
  694.      kbd.o : defs.h command.h
  695.      command.o : defs.h command.h
  696.      display.o : defs.h buffer.h
  697.      insert.o : defs.h buffer.h
  698.      search.o : defs.h buffer.h
  699.      files.o : defs.h buffer.h command.h
  700.      utils.o : defs.h
  701.  
  702.      .PHONY : clean
  703.      clean :
  704.              rm edit $(objects)
  705.  
  706. This is how we would write the makefile in actual practice.  (The
  707. complications associated with `clean' are described elsewhere.  See
  708. *Note Phony Targets::, and *Note Errors in Commands: Errors.)
  709.  
  710.    Because implicit rules are so convenient, they are important.  You
  711. will see them used frequently.
  712.  
  713. 
  714. File: make,  Node: Combine By Prerequisite,  Next: Cleanup,  Prev: make Deduces,  Up: Introduction
  715.  
  716. 2.6 Another Style of Makefile
  717. =============================
  718.  
  719. When the objects of a makefile are created only by implicit rules, an
  720. alternative style of makefile is possible.  In this style of makefile,
  721. you group entries by their prerequisites instead of by their targets.
  722. Here is what one looks like:
  723.  
  724.      objects = main.o kbd.o command.o display.o \
  725.                insert.o search.o files.o utils.o
  726.  
  727.      edit : $(objects)
  728.              cc -o edit $(objects)
  729.  
  730.      $(objects) : defs.h
  731.      kbd.o command.o files.o : command.h
  732.      display.o insert.o search.o files.o : buffer.h
  733.  
  734. Here `defs.h' is given as a prerequisite of all the object files;
  735. `command.h' and `buffer.h' are prerequisites of the specific object
  736. files listed for them.
  737.  
  738.    Whether this is better is a matter of taste: it is more compact, but
  739. some people dislike it because they find it clearer to put all the
  740. information about each target in one place.
  741.  
  742. 
  743. File: make,  Node: Cleanup,  Prev: Combine By Prerequisite,  Up: Introduction
  744.  
  745. 2.7 Rules for Cleaning the Directory
  746. ====================================
  747.  
  748. Compiling a program is not the only thing you might want to write rules
  749. for.  Makefiles commonly tell how to do a few other things besides
  750. compiling a program: for example, how to delete all the object files
  751. and executables so that the directory is `clean'.
  752.  
  753.    Here is how we could write a `make' rule for cleaning our example
  754. editor:
  755.  
  756.      clean:
  757.              rm edit $(objects)
  758.  
  759.    In practice, we might want to write the rule in a somewhat more
  760. complicated manner to handle unanticipated situations.  We would do
  761. this:
  762.  
  763.      .PHONY : clean
  764.      clean :
  765.              -rm edit $(objects)
  766.  
  767. This prevents `make' from getting confused by an actual file called
  768. `clean' and causes it to continue in spite of errors from `rm'.  (See
  769. *Note Phony Targets::, and *Note Errors in Commands: Errors.)
  770.  
  771. A rule such as this should not be placed at the beginning of the
  772. makefile, because we do not want it to run by default!  Thus, in the
  773. example makefile, we want the rule for `edit', which recompiles the
  774. editor, to remain the default goal.
  775.  
  776.    Since `clean' is not a prerequisite of `edit', this rule will not
  777. run at all if we give the command `make' with no arguments.  In order
  778. to make the rule run, we have to type `make clean'.  *Note How to Run
  779. `make': Running.
  780.  
  781. 
  782. File: make,  Node: Makefiles,  Next: Rules,  Prev: Introduction,  Up: Top
  783.  
  784. 3 Writing Makefiles
  785. *******************
  786.  
  787. The information that tells `make' how to recompile a system comes from
  788. reading a data base called the "makefile".
  789.  
  790. * Menu:
  791.  
  792. * Makefile Contents::           What makefiles contain.
  793. * Makefile Names::              How to name your makefile.
  794. * Include::                     How one makefile can use another makefile.
  795. * MAKEFILES Variable::          The environment can specify extra makefiles.
  796. * MAKEFILE_LIST Variable::      Discover which makefiles have been read.
  797. * Special Variables::           Other special variables.
  798. * Remaking Makefiles::          How makefiles get remade.
  799. * Overriding Makefiles::        How to override part of one makefile
  800.                                   with another makefile.
  801. * Reading Makefiles::           How makefiles are parsed.
  802.  
  803. 
  804. File: make,  Node: Makefile Contents,  Next: Makefile Names,  Prev: Makefiles,  Up: Makefiles
  805.  
  806. 3.1 What Makefiles Contain
  807. ==========================
  808.  
  809. Makefiles contain five kinds of things: "explicit rules", "implicit
  810. rules", "variable definitions", "directives", and "comments".  Rules,
  811. variables, and directives are described at length in later chapters.
  812.  
  813.    * An "explicit rule" says when and how to remake one or more files,
  814.      called the rule's targets.  It lists the other files that the
  815.      targets depend on, call the "prerequisites" of the target, and may
  816.      also give commands to use to create or update the targets.  *Note
  817.      Writing Rules: Rules.
  818.  
  819.    * An "implicit rule" says when and how to remake a class of files
  820.      based on their names.  It describes how a target may depend on a
  821.      file with a name similar to the target and gives commands to
  822.      create or update such a target.  *Note Using Implicit Rules:
  823.      Implicit Rules.
  824.  
  825.    * A "variable definition" is a line that specifies a text string
  826.      value for a variable that can be substituted into the text later.
  827.      The simple makefile example shows a variable definition for
  828.      `objects' as a list of all object files (*note Variables Make
  829.      Makefiles Simpler: Variables Simplify.).
  830.  
  831.    * A "directive" is a command for `make' to do something special while
  832.      reading the makefile.  These include:
  833.  
  834.         * Reading another makefile (*note Including Other Makefiles:
  835.           Include.).
  836.  
  837.         * Deciding (based on the values of variables) whether to use or
  838.           ignore a part of the makefile (*note Conditional Parts of
  839.           Makefiles: Conditionals.).
  840.  
  841.         * Defining a variable from a verbatim string containing
  842.           multiple lines (*note Defining Variables Verbatim: Defining.).
  843.  
  844.    * `#' in a line of a makefile starts a "comment".  It and the rest
  845.      of the line are ignored, except that a trailing backslash not
  846.      escaped by another backslash will continue the comment across
  847.      multiple lines.  A line containing just a comment (with perhaps
  848.      spaces before it) is effectively blank, and is ignored.  If you
  849.      want a literal `#', escape it with a backslash (e.g., `\#').
  850.      Comments may appear on any line in the makefile, although they are
  851.      treated specially in certain situations.
  852.  
  853.      Within a command script (if the line begins with a TAB character)
  854.      the entire line is passed to the shell, just as with any other
  855.      line that begins with a TAB.  The shell decides how to interpret
  856.      the text: whether or not this is a comment is up to the shell.
  857.  
  858.      Within a `define' directive, comments are not ignored during the
  859.      definition of the variable, but rather kept intact in the value of
  860.      the variable.  When the variable is expanded they will either be
  861.      treated as `make' comments or as command script text, depending on
  862.      the context in which the variable is evaluated.
  863.  
  864. 
  865. File: make,  Node: Makefile Names,  Next: Include,  Prev: Makefile Contents,  Up: Makefiles
  866.  
  867. 3.2 What Name to Give Your Makefile
  868. ===================================
  869.  
  870. By default, when `make' looks for the makefile, it tries the following
  871. names, in order: `GNUmakefile', `makefile' and `Makefile'.  
  872.  
  873.    Normally you should call your makefile either `makefile' or
  874. `Makefile'.  (We recommend `Makefile' because it appears prominently
  875. near the beginning of a directory listing, right near other important
  876. files such as `README'.)  The first name checked, `GNUmakefile', is not
  877. recommended for most makefiles.  You should use this name if you have a
  878. makefile that is specific to GNU `make', and will not be understood by
  879. other versions of `make'.  Other `make' programs look for `makefile' and
  880. `Makefile', but not `GNUmakefile'.
  881.  
  882.    If `make' finds none of these names, it does not use any makefile.
  883. Then you must specify a goal with a command argument, and `make' will
  884. attempt to figure out how to remake it using only its built-in implicit
  885. rules.  *Note Using Implicit Rules: Implicit Rules.
  886.  
  887.    If you want to use a nonstandard name for your makefile, you can
  888. specify the makefile name with the `-f' or `--file' option.  The
  889. arguments `-f NAME' or `--file=NAME' tell `make' to read the file NAME
  890. as the makefile.  If you use more than one `-f' or `--file' option, you
  891. can specify several makefiles.  All the makefiles are effectively
  892. concatenated in the order specified.  The default makefile names
  893. `GNUmakefile', `makefile' and `Makefile' are not checked automatically
  894. if you specify `-f' or `--file'.  
  895.  
  896. 
  897. File: make,  Node: Include,  Next: MAKEFILES Variable,  Prev: Makefile Names,  Up: Makefiles
  898.  
  899. 3.3 Including Other Makefiles
  900. =============================
  901.  
  902. The `include' directive tells `make' to suspend reading the current
  903. makefile and read one or more other makefiles before continuing.  The
  904. directive is a line in the makefile that looks like this:
  905.  
  906.      include FILENAMES...
  907.  
  908. FILENAMES can contain shell file name patterns.  
  909.  
  910.    Extra spaces are allowed and ignored at the beginning of the line,
  911. but a tab is not allowed.  (If the line begins with a tab, it will be
  912. considered a command line.)  Whitespace is required between `include'
  913. and the file names, and between file names; extra whitespace is ignored
  914. there and at the end of the directive.  A comment starting with `#' is
  915. allowed at the end of the line.  If the file names contain any variable
  916. or function references, they are expanded.  *Note How to Use Variables:
  917. Using Variables.
  918.  
  919.    For example, if you have three `.mk' files, `a.mk', `b.mk', and
  920. `c.mk', and `$(bar)' expands to `bish bash', then the following
  921. expression
  922.  
  923.      include foo *.mk $(bar)
  924.  
  925.    is equivalent to
  926.  
  927.      include foo a.mk b.mk c.mk bish bash
  928.  
  929.    When `make' processes an `include' directive, it suspends reading of
  930. the containing makefile and reads from each listed file in turn.  When
  931. that is finished, `make' resumes reading the makefile in which the
  932. directive appears.
  933.  
  934.    One occasion for using `include' directives is when several programs,
  935. handled by individual makefiles in various directories, need to use a
  936. common set of variable definitions (*note Setting Variables: Setting.)
  937. or pattern rules (*note Defining and Redefining Pattern Rules: Pattern
  938. Rules.).
  939.  
  940.    Another such occasion is when you want to generate prerequisites from
  941. source files automatically; the prerequisites can be put in a file that
  942. is included by the main makefile.  This practice is generally cleaner
  943. than that of somehow appending the prerequisites to the end of the main
  944. makefile as has been traditionally done with other versions of `make'.
  945. *Note Automatic Prerequisites::.  
  946.  
  947.    If the specified name does not start with a slash, and the file is
  948. not found in the current directory, several other directories are
  949. searched.  First, any directories you have specified with the `-I' or
  950. `--include-dir' option are searched (*note Summary of Options: Options
  951. Summary.).  Then the following directories (if they exist) are
  952. searched, in this order: `PREFIX/include' (normally `/usr/local/include'
  953. (1)) `/usr/gnu/include', `/usr/local/include', `/usr/include'.
  954.  
  955.    If an included makefile cannot be found in any of these directories,
  956. a warning message is generated, but it is not an immediately fatal
  957. error; processing of the makefile containing the `include' continues.
  958. Once it has finished reading makefiles, `make' will try to remake any
  959. that are out of date or don't exist.  *Note How Makefiles Are Remade:
  960. Remaking Makefiles.  Only after it has tried to find a way to remake a
  961. makefile and failed, will `make' diagnose the missing makefile as a
  962. fatal error.
  963.  
  964.    If you want `make' to simply ignore a makefile which does not exist
  965. and cannot be remade, with no error message, use the `-include'
  966. directive instead of `include', like this:
  967.  
  968.      -include FILENAMES...
  969.  
  970.    This acts like `include' in every way except that there is no error
  971. (not even a warning) if any of the FILENAMES do not exist.  For
  972. compatibility with some other `make' implementations, `sinclude' is
  973. another name for `-include'.
  974.  
  975.    ---------- Footnotes ----------
  976.  
  977.    (1) GNU Make compiled for MS-DOS and MS-Windows behaves as if PREFIX
  978. has been defined to be the root of the DJGPP tree hierarchy.
  979.  
  980. 
  981. File: make,  Node: MAKEFILES Variable,  Next: MAKEFILE_LIST Variable,  Prev: Include,  Up: Makefiles
  982.  
  983. 3.4 The Variable `MAKEFILES'
  984. ============================
  985.  
  986. If the environment variable `MAKEFILES' is defined, `make' considers
  987. its value as a list of names (separated by whitespace) of additional
  988. makefiles to be read before the others.  This works much like the
  989. `include' directive: various directories are searched for those files
  990. (*note Including Other Makefiles: Include.).  In addition, the default
  991. goal is never taken from one of these makefiles and it is not an error
  992. if the files listed in `MAKEFILES' are not found.
  993.  
  994.    The main use of `MAKEFILES' is in communication between recursive
  995. invocations of `make' (*note Recursive Use of `make': Recursion.).  It
  996. usually is not desirable to set the environment variable before a
  997. top-level invocation of `make', because it is usually better not to
  998. mess with a makefile from outside.  However, if you are running `make'
  999. without a specific makefile, a makefile in `MAKEFILES' can do useful
  1000. things to help the built-in implicit rules work better, such as
  1001. defining search paths (*note Directory Search::).
  1002.  
  1003.    Some users are tempted to set `MAKEFILES' in the environment
  1004. automatically on login, and program makefiles to expect this to be done.
  1005. This is a very bad idea, because such makefiles will fail to work if
  1006. run by anyone else.  It is much better to write explicit `include'
  1007. directives in the makefiles.  *Note Including Other Makefiles: Include.
  1008.  
  1009. 
  1010. File: make,  Node: MAKEFILE_LIST Variable,  Next: Special Variables,  Prev: MAKEFILES Variable,  Up: Makefiles
  1011.  
  1012. 3.5 The Variable `MAKEFILE_LIST'
  1013. ================================
  1014.  
  1015. As `make' reads various makefiles, including any obtained from the
  1016. `MAKEFILES' variable, the command line, the default files, or from
  1017. `include' directives, their names will be automatically appended to the
  1018. `MAKEFILE_LIST' variable.  They are added right before `make' begins to
  1019. parse them.
  1020.  
  1021.    This means that if the first thing a makefile does is examine the
  1022. last word in this variable, it will be the name of the current makefile.
  1023. Once the current makefile has used `include', however, the last word
  1024. will be the just-included makefile.
  1025.  
  1026.    If a makefile named `Makefile' has this content:
  1027.  
  1028.      name1 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
  1029.  
  1030.      include inc.mk
  1031.  
  1032.      name2 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
  1033.  
  1034.      all:
  1035.              @echo name1 = $(name1)
  1036.              @echo name2 = $(name2)
  1037.  
  1038. then you would expect to see this output:
  1039.  
  1040.      name1 = Makefile
  1041.      name2 = inc.mk
  1042.  
  1043.    *Note Text Functions::, for more information on the `word' and
  1044. `words' functions used above.  *Note The Two Flavors of Variables:
  1045. Flavors, for more information on simply-expanded (`:=') variable
  1046. definitions.
  1047.  
  1048. 
  1049. File: make,  Node: Special Variables,  Next: Remaking Makefiles,  Prev: MAKEFILE_LIST Variable,  Up: Makefiles
  1050.  
  1051. 3.6 Other Special Variables
  1052. ===========================
  1053.  
  1054. GNU `make' also supports a special variable.  Note that any value you
  1055. assign to this variable will be ignored; it will always return its
  1056. special value.
  1057.  
  1058.    The first special variable is `.VARIABLES'.  When expanded, the
  1059. value consists of a list of the _names_ of all global variables defined
  1060. in all makefiles read up until that point.  This includes variables
  1061. which have empty values, as well as built-in variables (*note Variables
  1062. Used by Implicit Rules: Implicit Variables.), but does not include any
  1063. variables which are only defined in a target-specific context.
  1064.  
  1065. 
  1066. File: make,  Node: Remaking Makefiles,  Next: Overriding Makefiles,  Prev: Special Variables,  Up: Makefiles
  1067.  
  1068. 3.7 How Makefiles Are Remade
  1069. ============================
  1070.  
  1071. Sometimes makefiles can be remade from other files, such as RCS or SCCS
  1072. files.  If a makefile can be remade from other files, you probably want
  1073. `make' to get an up-to-date version of the makefile to read in.
  1074.  
  1075.    To this end, after reading in all makefiles, `make' will consider
  1076. each as a goal target and attempt to update it.  If a makefile has a
  1077. rule which says how to update it (found either in that very makefile or
  1078. in another one) or if an implicit rule applies to it (*note Using
  1079. Implicit Rules: Implicit Rules.), it will be updated if necessary.
  1080. After all makefiles have been checked, if any have actually been
  1081. changed, `make' starts with a clean slate and reads all the makefiles
  1082. over again.  (It will also attempt to update each of them over again,
  1083. but normally this will not change them again, since they are already up
  1084. to date.)
  1085.  
  1086.    If you know that one or more of your makefiles cannot be remade and
  1087. you want to keep `make' from performing an implicit rule search on
  1088. them, perhaps for efficiency reasons, you can use any normal method of
  1089. preventing implicit rule lookup to do so.  For example, you can write an
  1090. explicit rule with the makefile as the target, and an empty command
  1091. string (*note Using Empty Commands: Empty Commands.).
  1092.  
  1093.    If the makefiles specify a double-colon rule to remake a file with
  1094. commands but no prerequisites, that file will always be remade (*note
  1095. Double-Colon::).  In the case of makefiles, a makefile that has a
  1096. double-colon rule with commands but no prerequisites will be remade
  1097. every time `make' is run, and then again after `make' starts over and
  1098. reads the makefiles in again.  This would cause an infinite loop:
  1099. `make' would constantly remake the makefile, and never do anything
  1100. else.  So, to avoid this, `make' will *not* attempt to remake makefiles
  1101. which are specified as targets of a double-colon rule with commands but
  1102. no prerequisites.
  1103.  
  1104.    If you do not specify any makefiles to be read with `-f' or `--file'
  1105. options, `make' will try the default makefile names; *note What Name to
  1106. Give Your Makefile: Makefile Names.  Unlike makefiles explicitly
  1107. requested with `-f' or `--file' options, `make' is not certain that
  1108. these makefiles should exist.  However, if a default makefile does not
  1109. exist but can be created by running `make' rules, you probably want the
  1110. rules to be run so that the makefile can be used.
  1111.  
  1112.    Therefore, if none of the default makefiles exists, `make' will try
  1113. to make each of them in the same order in which they are searched for
  1114. (*note What Name to Give Your Makefile: Makefile Names.)  until it
  1115. succeeds in making one, or it runs out of names to try.  Note that it
  1116. is not an error if `make' cannot find or make any makefile; a makefile
  1117. is not always necessary.
  1118.  
  1119.    When you use the `-t' or `--touch' option (*note Instead of
  1120. Executing the Commands: Instead of Execution.), you would not want to
  1121. use an out-of-date makefile to decide which targets to touch.  So the
  1122. `-t' option has no effect on updating makefiles; they are really
  1123. updated even if `-t' is specified.  Likewise, `-q' (or `--question')
  1124. and `-n' (or `--just-print') do not prevent updating of makefiles,
  1125. because an out-of-date makefile would result in the wrong output for
  1126. other targets.  Thus, `make -f mfile -n foo' will update `mfile', read
  1127. it in, and then print the commands to update `foo' and its prerequisites
  1128. without running them.  The commands printed for `foo' will be those
  1129. specified in the updated contents of `mfile'.
  1130.  
  1131.    However, on occasion you might actually wish to prevent updating of
  1132. even the makefiles.  You can do this by specifying the makefiles as
  1133. goals in the command line as well as specifying them as makefiles.
  1134. When the makefile name is specified explicitly as a goal, the options
  1135. `-t' and so on do apply to them.
  1136.  
  1137.    Thus, `make -f mfile -n mfile foo' would read the makefile `mfile',
  1138. print the commands needed to update it without actually running them,
  1139. and then print the commands needed to update `foo' without running
  1140. them.  The commands for `foo' will be those specified by the existing
  1141. contents of `mfile'.
  1142.  
  1143. 
  1144. File: make,  Node: Overriding Makefiles,  Next: Reading Makefiles,  Prev: Remaking Makefiles,  Up: Makefiles
  1145.  
  1146. 3.8 Overriding Part of Another Makefile
  1147. =======================================
  1148.  
  1149. Sometimes it is useful to have a makefile that is mostly just like
  1150. another makefile.  You can often use the `include' directive to include
  1151. one in the other, and add more targets or variable definitions.
  1152. However, if the two makefiles give different commands for the same
  1153. target, `make' will not let you just do this.  But there is another way.
  1154.  
  1155.    In the containing makefile (the one that wants to include the other),
  1156. you can use a match-anything pattern rule to say that to remake any
  1157. target that cannot be made from the information in the containing
  1158. makefile, `make' should look in another makefile.  *Note Pattern
  1159. Rules::, for more information on pattern rules.
  1160.  
  1161.    For example, if you have a makefile called `Makefile' that says how
  1162. to make the target `foo' (and other targets), you can write a makefile
  1163. called `GNUmakefile' that contains:
  1164.  
  1165.      foo:
  1166.              frobnicate > foo
  1167.  
  1168.      %: force
  1169.              @$(MAKE) -f Makefile $@
  1170.      force: ;
  1171.  
  1172.    If you say `make foo', `make' will find `GNUmakefile', read it, and
  1173. see that to make `foo', it needs to run the command `frobnicate > foo'.
  1174. If you say `make bar', `make' will find no way to make `bar' in
  1175. `GNUmakefile', so it will use the commands from the pattern rule: `make
  1176. -f Makefile bar'.  If `Makefile' provides a rule for updating `bar',
  1177. `make' will apply the rule.  And likewise for any other target that
  1178. `GNUmakefile' does not say how to make.
  1179.  
  1180.    The way this works is that the pattern rule has a pattern of just
  1181. `%', so it matches any target whatever.  The rule specifies a
  1182. prerequisite `force', to guarantee that the commands will be run even
  1183. if the target file already exists.  We give `force' target empty
  1184. commands to prevent `make' from searching for an implicit rule to build
  1185. it--otherwise it would apply the same match-anything rule to `force'
  1186. itself and create a prerequisite loop!
  1187.  
  1188. 
  1189. File: make,  Node: Reading Makefiles,  Prev: Overriding Makefiles,  Up: Makefiles
  1190.  
  1191. 3.9 How `make' Reads a Makefile
  1192. ===============================
  1193.  
  1194. GNU `make' does its work in two distinct phases.  During the first
  1195. phase it reads all the makefiles, included makefiles, etc. and
  1196. internalizes all the variables and their values, implicit and explicit
  1197. rules, and constructs a dependency graph of all the targets and their
  1198. prerequisites.  During the second phase, `make' uses these internal
  1199. structures to determine what targets will need to be rebuilt and to
  1200. invoke the rules necessary to do so.
  1201.  
  1202.    It's important to understand this two-phase approach because it has a
  1203. direct impact on how variable and function expansion happens; this is
  1204. often a source of some confusion when writing makefiles.  Here we will
  1205. present a summary of the phases in which expansion happens for different
  1206. constructs within the makefile.  We say that expansion is "immediate"
  1207. if it happens during the first phase: in this case `make' will expand
  1208. any variables or functions in that section of a construct as the
  1209. makefile is parsed.  We say that expansion is "deferred" if expansion
  1210. is not performed immediately.  Expansion of deferred construct is not
  1211. performed until either the construct appears later in an immediate
  1212. context, or until the second phase.
  1213.  
  1214.    You may not be familiar with some of these constructs yet.  You can
  1215. reference this section as you become familiar with them, in later
  1216. chapters.
  1217.  
  1218. Variable Assignment
  1219. -------------------
  1220.  
  1221. Variable definitions are parsed as follows:
  1222.  
  1223.      IMMEDIATE = DEFERRED
  1224.      IMMEDIATE ?= DEFERRED
  1225.      IMMEDIATE := IMMEDIATE
  1226.      IMMEDIATE += DEFERRED or IMMEDIATE
  1227.  
  1228.      define IMMEDIATE
  1229.        DEFERRED
  1230.      endef
  1231.  
  1232.    For the append operator, `+=', the right-hand side is considered
  1233. immediate if the variable was previously set as a simple variable
  1234. (`:='), and deferred otherwise.
  1235.  
  1236. Conditional Statements
  1237. ----------------------
  1238.  
  1239. All instances of conditional syntax are parsed immediately, in their
  1240. entirety; this includes the `ifdef', `ifeq', `ifndef', and `ifneq'
  1241. forms.
  1242.  
  1243. Rule Definition
  1244. ---------------
  1245.  
  1246. A rule is always expanded the same way, regardless of the form:
  1247.  
  1248.      IMMEDIATE : IMMEDIATE ; DEFERRED
  1249.          DEFERRED
  1250.  
  1251.    That is, the target and prerequisite sections are expanded
  1252. immediately, and the commands used to construct the target are always
  1253. deferred.  This general rule is true for explicit rules, pattern rules,
  1254. suffix rules, static pattern rules, and simple prerequisite definitions.
  1255.  
  1256. 
  1257. File: make,  Node: Rules,  Next: Commands,  Prev: Makefiles,  Up: Top
  1258.  
  1259. 4 Writing Rules
  1260. ***************
  1261.  
  1262. A "rule" appears in the makefile and says when and how to remake
  1263. certain files, called the rule's "targets" (most often only one per
  1264. rule).  It lists the other files that are the "prerequisites" of the
  1265. target, and "commands" to use to create or update the target.
  1266.  
  1267.    The order of rules is not significant, except for determining the
  1268. "default goal": the target for `make' to consider, if you do not
  1269. otherwise specify one.  The default goal is the target of the first
  1270. rule in the first makefile.  If the first rule has multiple targets,
  1271. only the first target is taken as the default.  There are two
  1272. exceptions: a target starting with a period is not a default unless it
  1273. contains one or more slashes, `/', as well; and, a target that defines
  1274. a pattern rule has no effect on the default goal.  (*Note Defining and
  1275. Redefining Pattern Rules: Pattern Rules.)
  1276.  
  1277.    Therefore, we usually write the makefile so that the first rule is
  1278. the one for compiling the entire program or all the programs described
  1279. by the makefile (often with a target called `all').  *Note Arguments to
  1280. Specify the Goals: Goals.
  1281.  
  1282. * Menu:
  1283.  
  1284. * Rule Example::                An example explained.
  1285. * Rule Syntax::                 General syntax explained.
  1286. * Prerequisite Types::          There are two types of prerequisites.
  1287. * Wildcards::                   Using wildcard characters such as `*'.
  1288. * Directory Search::            Searching other directories for source files.
  1289. * Phony Targets::               Using a target that is not a real file's name.
  1290. * Force Targets::               You can use a target without commands
  1291.                                   or prerequisites to mark other
  1292.                                   targets as phony.
  1293. * Empty Targets::               When only the date matters and the
  1294.                                   files are empty.
  1295. * Special Targets::             Targets with special built-in meanings.
  1296. * Multiple Targets::            When to make use of several targets in a rule.
  1297. * Multiple Rules::              How to use several rules with the same target.
  1298. * Static Pattern::              Static pattern rules apply to multiple targets
  1299.                                   and can vary the prerequisites according to
  1300.                                   the target name.
  1301. * Double-Colon::                How to use a special kind of rule to allow
  1302.                                   several independent rules for one target.
  1303. * Automatic Prerequisites::     How to automatically generate rules giving
  1304.                                   prerequisites from source files themselves.
  1305.  
  1306. 
  1307. File: make,  Node: Rule Example,  Next: Rule Syntax,  Prev: Rules,  Up: Rules
  1308.  
  1309. 4.1 Rule Example
  1310. ================
  1311.  
  1312. Here is an example of a rule:
  1313.  
  1314.      foo.o : foo.c defs.h       # module for twiddling the frobs
  1315.              cc -c -g foo.c
  1316.  
  1317.    Its target is `foo.o' and its prerequisites are `foo.c' and
  1318. `defs.h'.  It has one command, which is `cc -c -g foo.c'.  The command
  1319. line starts with a tab to identify it as a command.
  1320.  
  1321.    This rule says two things:
  1322.  
  1323.    * How to decide whether `foo.o' is out of date: it is out of date if
  1324.      it does not exist, or if either `foo.c' or `defs.h' is more recent
  1325.      than it.
  1326.  
  1327.    * How to update the file `foo.o': by running `cc' as stated.  The
  1328.      command does not explicitly mention `defs.h', but we presume that
  1329.      `foo.c' includes it, and that that is why `defs.h' was added to
  1330.      the prerequisites.
  1331.  
  1332. 
  1333. File: make,  Node: Rule Syntax,  Next: Prerequisite Types,  Prev: Rule Example,  Up: Rules
  1334.  
  1335. 4.2 Rule Syntax
  1336. ===============
  1337.  
  1338. In general, a rule looks like this:
  1339.  
  1340.      TARGETS : PREREQUISITES
  1341.              COMMAND
  1342.              ...
  1343.  
  1344. or like this:
  1345.  
  1346.      TARGETS : PREREQUISITES ; COMMAND
  1347.              COMMAND
  1348.              ...
  1349.  
  1350.    The TARGETS are file names, separated by spaces.  Wildcard
  1351. characters may be used (*note Using Wildcard Characters in File Names:
  1352. Wildcards.) and a name of the form `A(M)' represents member M in
  1353. archive file A (*note Archive Members as Targets: Archive Members.).
  1354. Usually there is only one target per rule, but occasionally there is a
  1355. reason to have more (*note Multiple Targets in a Rule: Multiple
  1356. Targets.).
  1357.  
  1358.    The COMMAND lines start with a tab character.  The first command may
  1359. appear on the line after the prerequisites, with a tab character, or may
  1360. appear on the same line, with a semicolon.  Either way, the effect is
  1361. the same.  *Note Writing the Commands in Rules: Commands.
  1362.  
  1363.    Because dollar signs are used to start variable references, if you
  1364. really want a dollar sign in a rule you must write two of them, `$$'
  1365. (*note How to Use Variables: Using Variables.).  You may split a long
  1366. line by inserting a backslash followed by a newline, but this is not
  1367. required, as `make' places no limit on the length of a line in a
  1368. makefile.
  1369.  
  1370.    A rule tells `make' two things: when the targets are out of date,
  1371. and how to update them when necessary.
  1372.  
  1373.    The criterion for being out of date is specified in terms of the
  1374. PREREQUISITES, which consist of file names separated by spaces.
  1375. (Wildcards and archive members (*note Archives::) are allowed here too.)
  1376. A target is out of date if it does not exist or if it is older than any
  1377. of the prerequisites (by comparison of last-modification times).  The
  1378. idea is that the contents of the target file are computed based on
  1379. information in the prerequisites, so if any of the prerequisites
  1380. changes, the contents of the existing target file are no longer
  1381. necessarily valid.
  1382.  
  1383.    How to update is specified by COMMANDS.  These are lines to be
  1384. executed by the shell (normally `sh'), but with some extra features
  1385. (*note Writing the Commands in Rules: Commands.).
  1386.  
  1387. 
  1388. File: make,  Node: Prerequisite Types,  Next: Wildcards,  Prev: Rule Syntax,  Up: Rules
  1389.  
  1390. 4.3 Types of Prerequisites
  1391. ==========================
  1392.  
  1393. There are actually two different types of prerequisites understood by
  1394. GNU `make': normal prerequisites such as described in the previous
  1395. section, and "order-only" prerequisites.  A normal prerequisite
  1396. actually makes two statements: first, it imposes an order of execution
  1397. of build commands: any commands necessary to build any of a target's
  1398. prerequisites will be fully executed before any commands necessary to
  1399. build the target.  Second, it imposes a dependency relationship: if any
  1400. prerequisite is newer than the target, then the target is considered
  1401. out-of-date and must be rebuilt.
  1402.  
  1403.    Normally, this is exactly what you want: if a target's prerequisite
  1404. is updated, then the target should also be updated.
  1405.  
  1406.    Occasionally, however, you have a situation where you want to impose
  1407. a specific ordering on the rules to be invoked _without_ forcing the
  1408. target to be updated if one of those rules is executed.  In that case,
  1409. you want to define "order-only" prerequisites.  Order-only
  1410. prerequisites can be specified by placing a pipe symbol (`|') in the
  1411. prerequisites list: any prerequisites to the left of the pipe symbol
  1412. are normal; any prerequisites to the right are order-only:
  1413.  
  1414.      TARGETS : NORMAL-PREREQUISITES | ORDER-ONLY-PREREQUISITES
  1415.  
  1416.    The normal prerequisites section may of course be empty.  Also, you
  1417. may still declare multiple lines of prerequisites for the same target:
  1418. they are appended appropriately.  Note that if you declare the same
  1419. file to be both a normal and an order-only prerequisite, the normal
  1420. prerequisite takes precedence (since they are a strict superset of the
  1421. behavior of an order-only prerequisite).
  1422.  
  1423. 
  1424. File: make,  Node: Wildcards,  Next: Directory Search,  Prev: Prerequisite Types,  Up: Rules
  1425.  
  1426. 4.4 Using Wildcard Characters in File Names
  1427. ===========================================
  1428.  
  1429. A single file name can specify many files using "wildcard characters".
  1430. The wildcard characters in `make' are `*', `?' and `[...]', the same as
  1431. in the Bourne shell.  For example, `*.c' specifies a list of all the
  1432. files (in the working directory) whose names end in `.c'.
  1433.  
  1434.    The character `~' at the beginning of a file name also has special
  1435. significance.  If alone, or followed by a slash, it represents your home
  1436. directory.  For example `~/bin' expands to `/home/you/bin'.  If the `~'
  1437. is followed by a word, the string represents the home directory of the
  1438. user named by that word.  For example `~john/bin' expands to
  1439. `/home/john/bin'.  On systems which don't have a home directory for
  1440. each user (such as MS-DOS or MS-Windows), this functionality can be
  1441. simulated by setting the environment variable HOME.
  1442.  
  1443.    Wildcard expansion happens automatically in targets, in
  1444. prerequisites, and in commands (where the shell does the expansion).
  1445. In other contexts, wildcard expansion happens only if you request it
  1446. explicitly with the `wildcard' function.
  1447.  
  1448.    The special significance of a wildcard character can be turned off by
  1449. preceding it with a backslash.  Thus, `foo\*bar' would refer to a
  1450. specific file whose name consists of `foo', an asterisk, and `bar'.
  1451.  
  1452. * Menu:
  1453.  
  1454. * Wildcard Examples::           Several examples
  1455. * Wildcard Pitfall::            Problems to avoid.
  1456. * Wildcard Function::           How to cause wildcard expansion where
  1457.                                   it does not normally take place.
  1458.  
  1459. 
  1460. File: make,  Node: Wildcard Examples,  Next: Wildcard Pitfall,  Prev: Wildcards,  Up: Wildcards
  1461.  
  1462. 4.4.1 Wildcard Examples
  1463. -----------------------
  1464.  
  1465. Wildcards can be used in the commands of a rule, where they are expanded
  1466. by the shell.  For example, here is a rule to delete all the object
  1467. files:
  1468.  
  1469.      clean:
  1470.              rm -f *.o
  1471.  
  1472.    Wildcards are also useful in the prerequisites of a rule.  With the
  1473. following rule in the makefile, `make print' will print all the `.c'
  1474. files that have changed since the last time you printed them:
  1475.  
  1476.      print: *.c
  1477.              lpr -p $?
  1478.              touch print
  1479.  
  1480. This rule uses `print' as an empty target file; see *Note Empty Target
  1481. Files to Record Events: Empty Targets.  (The automatic variable `$?' is
  1482. used to print only those files that have changed; see *Note Automatic
  1483. Variables: Automatic.)
  1484.  
  1485.    Wildcard expansion does not happen when you define a variable.
  1486. Thus, if you write this:
  1487.  
  1488.      objects = *.o
  1489.  
  1490. then the value of the variable `objects' is the actual string `*.o'.
  1491. However, if you use the value of `objects' in a target, prerequisite or
  1492. command, wildcard expansion will take place at that time.  To set
  1493. `objects' to the expansion, instead use:
  1494.  
  1495.      objects := $(wildcard *.o)
  1496.  
  1497. *Note Wildcard Function::.
  1498.  
  1499. 
  1500. File: make,  Node: Wildcard Pitfall,  Next: Wildcard Function,  Prev: Wildcard Examples,  Up: Wildcards
  1501.  
  1502. 4.4.2 Pitfalls of Using Wildcards
  1503. ---------------------------------
  1504.  
  1505. Now here is an example of a naive way of using wildcard expansion, that
  1506. does not do what you would intend.  Suppose you would like to say that
  1507. the executable file `foo' is made from all the object files in the
  1508. directory, and you write this:
  1509.  
  1510.      objects = *.o
  1511.  
  1512.      foo : $(objects)
  1513.              cc -o foo $(CFLAGS) $(objects)
  1514.  
  1515. The value of `objects' is the actual string `*.o'.  Wildcard expansion
  1516. happens in the rule for `foo', so that each _existing_ `.o' file
  1517. becomes a prerequisite of `foo' and will be recompiled if necessary.
  1518.  
  1519.    But what if you delete all the `.o' files?  When a wildcard matches
  1520. no files, it is left as it is, so then `foo' will depend on the
  1521. oddly-named file `*.o'.  Since no such file is likely to exist, `make'
  1522. will give you an error saying it cannot figure out how to make `*.o'.
  1523. This is not what you want!
  1524.  
  1525.    Actually it is possible to obtain the desired result with wildcard
  1526. expansion, but you need more sophisticated techniques, including the
  1527. `wildcard' function and string substitution.  *Note The Function
  1528. `wildcard': Wildcard Function.
  1529.  
  1530.    Microsoft operating systems (MS-DOS and MS-Windows) use backslashes
  1531. to separate directories in pathnames, like so:
  1532.  
  1533.        c:\foo\bar\baz.c
  1534.  
  1535.    This is equivalent to the Unix-style `c:/foo/bar/baz.c' (the `c:'
  1536. part is the so-called drive letter).  When `make' runs on these
  1537. systems, it supports backslashes as well as the Unix-style forward
  1538. slashes in pathnames.  However, this support does _not_ include the
  1539. wildcard expansion, where backslash is a quote character.  Therefore,
  1540. you _must_ use Unix-style slashes in these cases.
  1541.  
  1542. 
  1543. File: make,  Node: Wildcard Function,  Prev: Wildcard Pitfall,  Up: Wildcards
  1544.  
  1545. 4.4.3 The Function `wildcard'
  1546. -----------------------------
  1547.  
  1548. Wildcard expansion happens automatically in rules.  But wildcard
  1549. expansion does not normally take place when a variable is set, or
  1550. inside the arguments of a function.  If you want to do wildcard
  1551. expansion in such places, you need to use the `wildcard' function, like
  1552. this:
  1553.  
  1554.      $(wildcard PATTERN...)
  1555.  
  1556. This string, used anywhere in a makefile, is replaced by a
  1557. space-separated list of names of existing files that match one of the
  1558. given file name patterns.  If no existing file name matches a pattern,
  1559. then that pattern is omitted from the output of the `wildcard'
  1560. function.  Note that this is different from how unmatched wildcards
  1561. behave in rules, where they are used verbatim rather than ignored
  1562. (*note Wildcard Pitfall::).
  1563.  
  1564.    One use of the `wildcard' function is to get a list of all the C
  1565. source files in a directory, like this:
  1566.  
  1567.      $(wildcard *.c)
  1568.  
  1569.    We can change the list of C source files into a list of object files
  1570. by replacing the `.c' suffix with `.o' in the result, like this:
  1571.  
  1572.      $(patsubst %.c,%.o,$(wildcard *.c))
  1573.  
  1574. (Here we have used another function, `patsubst'.  *Note Functions for
  1575. String Substitution and Analysis: Text Functions.)
  1576.  
  1577.    Thus, a makefile to compile all C source files in the directory and
  1578. then link them together could be written as follows:
  1579.  
  1580.      objects := $(patsubst %.c,%.o,$(wildcard *.c))
  1581.  
  1582.      foo : $(objects)
  1583.              cc -o foo $(objects)
  1584.  
  1585. (This takes advantage of the implicit rule for compiling C programs, so
  1586. there is no need to write explicit rules for compiling the files.
  1587. *Note The Two Flavors of Variables: Flavors, for an explanation of
  1588. `:=', which is a variant of `='.)
  1589.  
  1590. 
  1591. File: make,  Node: Directory Search,  Next: Phony Targets,  Prev: Wildcards,  Up: Rules
  1592.  
  1593. 4.5 Searching Directories for Prerequisites
  1594. ===========================================
  1595.  
  1596. For large systems, it is often desirable to put sources in a separate
  1597. directory from the binaries.  The "directory search" features of `make'
  1598. facilitate this by searching several directories automatically to find
  1599. a prerequisite.  When you redistribute the files among directories, you
  1600. do not need to change the individual rules, just the search paths.
  1601.  
  1602. * Menu:
  1603.  
  1604. * General Search::              Specifying a search path that applies
  1605.                                   to every prerequisite.
  1606. * Selective Search::            Specifying a search path
  1607.                                   for a specified class of names.
  1608. * Search Algorithm::            When and how search paths are applied.
  1609. * Commands/Search::             How to write shell commands that work together
  1610.                                   with search paths.
  1611. * Implicit/Search::             How search paths affect implicit rules.
  1612. * Libraries/Search::            Directory search for link libraries.
  1613.  
  1614. 
  1615. File: make,  Node: General Search,  Next: Selective Search,  Prev: Directory Search,  Up: Directory Search
  1616.  
  1617. 4.5.1 `VPATH': Search Path for All Prerequisites
  1618. ------------------------------------------------
  1619.  
  1620. The value of the `make' variable `VPATH' specifies a list of
  1621. directories that `make' should search.  Most often, the directories are
  1622. expected to contain prerequisite files that are not in the current
  1623. directory; however, `VPATH' specifies a search list that `make' applies
  1624. for all files, including files which are targets of rules.
  1625.  
  1626.    Thus, if a file that is listed as a target or prerequisite does not
  1627. exist in the current directory, `make' searches the directories listed
  1628. in `VPATH' for a file with that name.  If a file is found in one of
  1629. them, that file may become the prerequisite (see below).  Rules may then
  1630. specify the names of files in the prerequisite list as if they all
  1631. existed in the current directory.  *Note Writing Shell Commands with
  1632. Directory Search: Commands/Search.
  1633.  
  1634.    In the `VPATH' variable, directory names are separated by colons or
  1635. blanks.  The order in which directories are listed is the order followed
  1636. by `make' in its search.  (On MS-DOS and MS-Windows, semi-colons are
  1637. used as separators of directory names in `VPATH', since the colon can
  1638. be used in the pathname itself, after the drive letter.)
  1639.  
  1640.    For example,
  1641.  
  1642.      VPATH = src:../headers
  1643.  
  1644. specifies a path containing two directories, `src' and `../headers',
  1645. which `make' searches in that order.
  1646.  
  1647.    With this value of `VPATH', the following rule,
  1648.  
  1649.      foo.o : foo.c
  1650.  
  1651. is interpreted as if it were written like this:
  1652.  
  1653.      foo.o : src/foo.c
  1654.  
  1655. assuming the file `foo.c' does not exist in the current directory but
  1656. is found in the directory `src'.
  1657.  
  1658. 
  1659. File: make,  Node: Selective Search,  Next: Search Algorithm,  Prev: General Search,  Up: Directory Search
  1660.  
  1661. 4.5.2 The `vpath' Directive
  1662. ---------------------------
  1663.  
  1664. Similar to the `VPATH' variable, but more selective, is the `vpath'
  1665. directive (note lower case), which allows you to specify a search path
  1666. for a particular class of file names: those that match a particular
  1667. pattern.  Thus you can supply certain search directories for one class
  1668. of file names and other directories (or none) for other file names.
  1669.  
  1670.    There are three forms of the `vpath' directive:
  1671.  
  1672. `vpath PATTERN DIRECTORIES'
  1673.      Specify the search path DIRECTORIES for file names that match
  1674.      PATTERN.
  1675.  
  1676.      The search path, DIRECTORIES, is a list of directories to be
  1677.      searched, separated by colons (semi-colons on MS-DOS and
  1678.      MS-Windows) or blanks, just like the search path used in the
  1679.      `VPATH' variable.
  1680.  
  1681. `vpath PATTERN'
  1682.      Clear out the search path associated with PATTERN.
  1683.  
  1684. `vpath'
  1685.      Clear all search paths previously specified with `vpath'
  1686.      directives.
  1687.  
  1688.    A `vpath' pattern is a string containing a `%' character.  The
  1689. string must match the file name of a prerequisite that is being searched
  1690. for, the `%' character matching any sequence of zero or more characters
  1691. (as in pattern rules; *note Defining and Redefining Pattern Rules:
  1692. Pattern Rules.).  For example, `%.h' matches files that end in `.h'.
  1693. (If there is no `%', the pattern must match the prerequisite exactly,
  1694. which is not useful very often.)
  1695.  
  1696.    `%' characters in a `vpath' directive's pattern can be quoted with
  1697. preceding backslashes (`\').  Backslashes that would otherwise quote
  1698. `%' characters can be quoted with more backslashes.  Backslashes that
  1699. quote `%' characters or other backslashes are removed from the pattern
  1700. before it is compared to file names.  Backslashes that are not in
  1701. danger of quoting `%' characters go unmolested.
  1702.  
  1703.    When a prerequisite fails to exist in the current directory, if the
  1704. PATTERN in a `vpath' directive matches the name of the prerequisite
  1705. file, then the DIRECTORIES in that directive are searched just like
  1706. (and before) the directories in the `VPATH' variable.
  1707.  
  1708.    For example,
  1709.  
  1710.      vpath %.h ../headers
  1711.  
  1712. tells `make' to look for any prerequisite whose name ends in `.h' in
  1713. the directory `../headers' if the file is not found in the current
  1714. directory.
  1715.  
  1716.    If several `vpath' patterns match the prerequisite file's name, then
  1717. `make' processes each matching `vpath' directive one by one, searching
  1718. all the directories mentioned in each directive.  `make' handles
  1719. multiple `vpath' directives in the order in which they appear in the
  1720. makefile; multiple directives with the same pattern are independent of
  1721. each other.
  1722.  
  1723.    Thus,
  1724.  
  1725.      vpath %.c foo
  1726.      vpath %   blish
  1727.      vpath %.c bar
  1728.  
  1729. will look for a file ending in `.c' in `foo', then `blish', then `bar',
  1730. while
  1731.  
  1732.      vpath %.c foo:bar
  1733.      vpath %   blish
  1734.  
  1735. will look for a file ending in `.c' in `foo', then `bar', then `blish'.
  1736.  
  1737. 
  1738. File: make,  Node: Search Algorithm,  Next: Commands/Search,  Prev: Selective Search,  Up: Directory Search
  1739.  
  1740. 4.5.3 How Directory Searches are Performed
  1741. ------------------------------------------
  1742.  
  1743. When a prerequisite is found through directory search, regardless of
  1744. type (general or selective), the pathname located may not be the one
  1745. that `make' actually provides you in the prerequisite list.  Sometimes
  1746. the path discovered through directory search is thrown away.
  1747.  
  1748.    The algorithm `make' uses to decide whether to keep or abandon a
  1749. path found via directory search is as follows:
  1750.  
  1751.   1. If a target file does not exist at the path specified in the
  1752.      makefile, directory search is performed.
  1753.  
  1754.   2. If the directory search is successful, that path is kept and this
  1755.      file is tentatively stored as the target.
  1756.  
  1757.   3. All prerequisites of this target are examined using this same
  1758.      method.
  1759.  
  1760.   4. After processing the prerequisites, the target may or may not need
  1761.      to be rebuilt:
  1762.  
  1763.        a. If the target does _not_ need to be rebuilt, the path to the
  1764.           file found during directory search is used for any
  1765.           prerequisite lists which contain this target.  In short, if
  1766.           `make' doesn't need to rebuild the target then you use the
  1767.           path found via directory search.
  1768.  
  1769.        b. If the target _does_ need to be rebuilt (is out-of-date), the
  1770.           pathname found during directory search is _thrown away_, and
  1771.           the target is rebuilt using the file name specified in the
  1772.           makefile.  In short, if `make' must rebuild, then the target
  1773.           is rebuilt locally, not in the directory found via directory
  1774.           search.
  1775.  
  1776.    This algorithm may seem complex, but in practice it is quite often
  1777. exactly what you want.
  1778.  
  1779.    Other versions of `make' use a simpler algorithm: if the file does
  1780. not exist, and it is found via directory search, then that pathname is
  1781. always used whether or not the target needs to be built.  Thus, if the
  1782. target is rebuilt it is created at the pathname discovered during
  1783. directory search.
  1784.  
  1785.    If, in fact, this is the behavior you want for some or all of your
  1786. directories, you can use the `GPATH' variable to indicate this to
  1787. `make'.
  1788.  
  1789.    `GPATH' has the same syntax and format as `VPATH' (that is, a space-
  1790. or colon-delimited list of pathnames).  If an out-of-date target is
  1791. found by directory search in a directory that also appears in `GPATH',
  1792. then that pathname is not thrown away.  The target is rebuilt using the
  1793. expanded path.
  1794.  
  1795. 
  1796. File: make,  Node: Commands/Search,  Next: Implicit/Search,  Prev: Search Algorithm,  Up: Directory Search
  1797.  
  1798. 4.5.4 Writing Shell Commands with Directory Search
  1799. --------------------------------------------------
  1800.  
  1801. When a prerequisite is found in another directory through directory
  1802. search, this cannot change the commands of the rule; they will execute
  1803. as written.  Therefore, you must write the commands with care so that
  1804. they will look for the prerequisite in the directory where `make' finds
  1805. it.
  1806.  
  1807.    This is done with the "automatic variables" such as `$^' (*note
  1808. Automatic Variables: Automatic.).  For instance, the value of `$^' is a
  1809. list of all the prerequisites of the rule, including the names of the
  1810. directories in which they were found, and the value of `$@' is the
  1811. target.  Thus:
  1812.  
  1813.      foo.o : foo.c
  1814.              cc -c $(CFLAGS) $^ -o $@
  1815.  
  1816. (The variable `CFLAGS' exists so you can specify flags for C
  1817. compilation by implicit rules; we use it here for consistency so it will
  1818. affect all C compilations uniformly; *note Variables Used by Implicit
  1819. Rules: Implicit Variables.)
  1820.  
  1821.    Often the prerequisites include header files as well, which you do
  1822. not want to mention in the commands.  The automatic variable `$<' is
  1823. just the first prerequisite:
  1824.  
  1825.      VPATH = src:../headers
  1826.      foo.o : foo.c defs.h hack.h
  1827.              cc -c $(CFLAGS) $< -o $@
  1828.  
  1829. 
  1830. File: make,  Node: Implicit/Search,  Next: Libraries/Search,  Prev: Commands/Search,  Up: Directory Search
  1831.  
  1832. 4.5.5 Directory Search and Implicit Rules
  1833. -----------------------------------------
  1834.  
  1835. The search through the directories specified in `VPATH' or with `vpath'
  1836. also happens during consideration of implicit rules (*note Using
  1837. Implicit Rules: Implicit Rules.).
  1838.  
  1839.    For example, when a file `foo.o' has no explicit rule, `make'
  1840. considers implicit rules, such as the built-in rule to compile `foo.c'
  1841. if that file exists.  If such a file is lacking in the current
  1842. directory, the appropriate directories are searched for it.  If `foo.c'
  1843. exists (or is mentioned in the makefile) in any of the directories, the
  1844. implicit rule for C compilation is applied.
  1845.  
  1846.    The commands of implicit rules normally use automatic variables as a
  1847. matter of necessity; consequently they will use the file names found by
  1848. directory search with no extra effort.
  1849.  
  1850. 
  1851. File: make,  Node: Libraries/Search,  Prev: Implicit/Search,  Up: Directory Search
  1852.  
  1853. 4.5.6 Directory Search for Link Libraries
  1854. -----------------------------------------
  1855.  
  1856. Directory search applies in a special way to libraries used with the
  1857. linker.  This special feature comes into play when you write a
  1858. prerequisite whose name is of the form `-lNAME'.  (You can tell
  1859. something strange is going on here because the prerequisite is normally
  1860. the name of a file, and the _file name_ of a library generally looks
  1861. like `libNAME.a', not like `-lNAME'.)
  1862.  
  1863.    When a prerequisite's name has the form `-lNAME', `make' handles it
  1864. specially by searching for the file `libNAME.so' in the current
  1865. directory, in directories specified by matching `vpath' search paths
  1866. and the `VPATH' search path, and then in the directories `/lib',
  1867. `/usr/lib', and `PREFIX/lib' (normally `/usr/local/lib', but
  1868. MS-DOS/MS-Windows versions of `make' behave as if PREFIX is defined to
  1869. be the root of the DJGPP installation tree).
  1870.  
  1871.    If that file is not found, then the file `libNAME.a' is searched
  1872. for, in the same directories as above.
  1873.  
  1874.    For example, if there is a `/usr/lib/libcurses.a' library on your
  1875. system (and no `/usr/lib/libcurses.so' file), then
  1876.  
  1877.      foo : foo.c -lcurses
  1878.              cc $^ -o $@
  1879.  
  1880. would cause the command `cc foo.c /usr/lib/libcurses.a -o foo' to be
  1881. executed when `foo' is older than `foo.c' or than
  1882. `/usr/lib/libcurses.a'.
  1883.  
  1884.    Although the default set of files to be searched for is `libNAME.so'
  1885. and `libNAME.a', this is customizable via the `.LIBPATTERNS' variable.
  1886. Each word in the value of this variable is a pattern string.  When a
  1887. prerequisite like `-lNAME' is seen, `make' will replace the percent in
  1888. each pattern in the list with NAME and perform the above directory
  1889. searches using that library filename.  If no library is found, the next
  1890. word in the list will be used.
  1891.  
  1892.    The default value for `.LIBPATTERNS' is "`lib%.so lib%.a'", which
  1893. provides the default behavior described above.
  1894.  
  1895.    You can turn off link library expansion completely by setting this
  1896. variable to an empty value.
  1897.  
  1898. 
  1899. File: make,  Node: Phony Targets,  Next: Force Targets,  Prev: Directory Search,  Up: Rules
  1900.  
  1901. 4.6 Phony Targets
  1902. =================
  1903.  
  1904. A phony target is one that is not really the name of a file.  It is
  1905. just a name for some commands to be executed when you make an explicit
  1906. request.  There are two reasons to use a phony target: to avoid a
  1907. conflict with a file of the same name, and to improve performance.
  1908.  
  1909.    If you write a rule whose commands will not create the target file,
  1910. the commands will be executed every time the target comes up for
  1911. remaking.  Here is an example:
  1912.  
  1913.      clean:
  1914.              rm *.o temp
  1915.  
  1916. Because the `rm' command does not create a file named `clean', probably
  1917. no such file will ever exist.  Therefore, the `rm' command will be
  1918. executed every time you say `make clean'.  
  1919.  
  1920.    The phony target will cease to work if anything ever does create a
  1921. file named `clean' in this directory.  Since it has no prerequisites,
  1922. the file `clean' would inevitably be considered up to date, and its
  1923. commands would not be executed.  To avoid this problem, you can
  1924. explicitly declare the target to be phony, using the special target
  1925. `.PHONY' (*note Special Built-in Target Names: Special Targets.) as
  1926. follows:
  1927.  
  1928.      .PHONY : clean
  1929.  
  1930. Once this is done, `make clean' will run the commands regardless of
  1931. whether there is a file named `clean'.
  1932.  
  1933.    Since it knows that phony targets do not name actual files that
  1934. could be remade from other files, `make' skips the implicit rule search
  1935. for phony targets (*note Implicit Rules::).  This is why declaring a
  1936. target phony is good for performance, even if you are not worried about
  1937. the actual file existing.
  1938.  
  1939.    Thus, you first write the line that states that `clean' is a phony
  1940. target, then you write the rule, like this:
  1941.  
  1942.      .PHONY: clean
  1943.      clean:
  1944.              rm *.o temp
  1945.  
  1946.    Another example of the usefulness of phony targets is in conjunction
  1947. with recursive invocations of `make' (for more information, see *Note
  1948. Recursive Use of `make': Recursion.).  In this case the makefile will
  1949. often contain a variable which lists a number of subdirectories to be
  1950. built.  One way to handle this is with one rule whose command is a
  1951. shell loop over the subdirectories, like this:
  1952.  
  1953.      SUBDIRS = foo bar baz
  1954.  
  1955.      subdirs:
  1956.              for dir in $(SUBDIRS); do \
  1957.                $(MAKE) -C $$dir; \
  1958.              done
  1959.  
  1960.    There are a few problems with this method, however.  First, any error
  1961. detected in a submake is not noted by this rule, so it will continue to
  1962. build the rest of the directories even when one fails.  This can be
  1963. overcome by adding shell commands to note the error and exit, but then
  1964. it will do so even if `make' is invoked with the `-k' option, which is
  1965. unfortunate.  Second, and perhaps more importantly, you cannot take
  1966. advantage of the parallel build capabilities of make using this method,
  1967. since there is only one rule.
  1968.  
  1969.    By declaring the subdirectories as phony targets (you must do this as
  1970. the subdirectory obviously always exists; otherwise it won't be built)
  1971. you can remove these problems:
  1972.  
  1973.      SUBDIRS = foo bar baz
  1974.  
  1975.      .PHONY: subdirs $(SUBDIRS)
  1976.  
  1977.      subdirs: $(SUBDIRS)
  1978.  
  1979.      $(SUBDIRS):
  1980.              $(MAKE) -C $@
  1981.  
  1982.      foo: baz
  1983.  
  1984.    Here we've also declared that the `foo' subdirectory cannot be built
  1985. until after the `baz' subdirectory is complete; this kind of
  1986. relationship declaration is particularly important when attempting
  1987. parallel builds.
  1988.  
  1989.    A phony target should not be a prerequisite of a real target file;
  1990. if it is, its commands are run every time `make' goes to update that
  1991. file.  As long as a phony target is never a prerequisite of a real
  1992. target, the phony target commands will be executed only when the phony
  1993. target is a specified goal (*note Arguments to Specify the Goals:
  1994. Goals.).
  1995.  
  1996.    Phony targets can have prerequisites.  When one directory contains
  1997. multiple programs, it is most convenient to describe all of the
  1998. programs in one makefile `./Makefile'.  Since the target remade by
  1999. default will be the first one in the makefile, it is common to make
  2000. this a phony target named `all' and give it, as prerequisites, all the
  2001. individual programs.  For example:
  2002.  
  2003.      all : prog1 prog2 prog3
  2004.      .PHONY : all
  2005.  
  2006.      prog1 : prog1.o utils.o
  2007.              cc -o prog1 prog1.o utils.o
  2008.  
  2009.      prog2 : prog2.o
  2010.              cc -o prog2 prog2.o
  2011.  
  2012.      prog3 : prog3.o sort.o utils.o
  2013.              cc -o prog3 prog3.o sort.o utils.o
  2014.  
  2015. Now you can say just `make' to remake all three programs, or specify as
  2016. arguments the ones to remake (as in `make prog1 prog3').
  2017.  
  2018.    When one phony target is a prerequisite of another, it serves as a
  2019. subroutine of the other.  For example, here `make cleanall' will delete
  2020. the object files, the difference files, and the file `program':
  2021.  
  2022.      .PHONY: cleanall cleanobj cleandiff
  2023.  
  2024.      cleanall : cleanobj cleandiff
  2025.              rm program
  2026.  
  2027.      cleanobj :
  2028.              rm *.o
  2029.  
  2030.      cleandiff :
  2031.              rm *.diff
  2032.  
  2033. 
  2034. File: make,  Node: Force Targets,  Next: Empty Targets,  Prev: Phony Targets,  Up: Rules
  2035.  
  2036. 4.7 Rules without Commands or Prerequisites
  2037. ===========================================
  2038.  
  2039. If a rule has no prerequisites or commands, and the target of the rule
  2040. is a nonexistent file, then `make' imagines this target to have been
  2041. updated whenever its rule is run.  This implies that all targets
  2042. depending on this one will always have their commands run.
  2043.  
  2044.    An example will illustrate this:
  2045.  
  2046.      clean: FORCE
  2047.              rm $(objects)
  2048.      FORCE:
  2049.  
  2050.    Here the target `FORCE' satisfies the special conditions, so the
  2051. target `clean' that depends on it is forced to run its commands.  There
  2052. is nothing special about the name `FORCE', but that is one name
  2053. commonly used this way.
  2054.  
  2055.    As you can see, using `FORCE' this way has the same results as using
  2056. `.PHONY: clean'.
  2057.  
  2058.    Using `.PHONY' is more explicit and more efficient.  However, other
  2059. versions of `make' do not support `.PHONY'; thus `FORCE' appears in
  2060. many makefiles.  *Note Phony Targets::.
  2061.  
  2062. 
  2063. File: make,  Node: Empty Targets,  Next: Special Targets,  Prev: Force Targets,  Up: Rules
  2064.  
  2065. 4.8 Empty Target Files to Record Events
  2066. =======================================
  2067.  
  2068. The "empty target" is a variant of the phony target; it is used to hold
  2069. commands for an action that you request explicitly from time to time.
  2070. Unlike a phony target, this target file can really exist; but the file's
  2071. contents do not matter, and usually are empty.
  2072.  
  2073.    The purpose of the empty target file is to record, with its
  2074. last-modification time, when the rule's commands were last executed.  It
  2075. does so because one of the commands is a `touch' command to update the
  2076. target file.
  2077.  
  2078.    The empty target file should have some prerequisites (otherwise it
  2079. doesn't make sense).  When you ask to remake the empty target, the
  2080. commands are executed if any prerequisite is more recent than the
  2081. target; in other words, if a prerequisite has changed since the last
  2082. time you remade the target.  Here is an example:
  2083.  
  2084.      print: foo.c bar.c
  2085.              lpr -p $?
  2086.              touch print
  2087.    
  2088. With this rule, `make print' will execute the `lpr' command if either
  2089. source file has changed since the last `make print'.  The automatic
  2090. variable `$?' is used to print only those files that have changed
  2091. (*note Automatic Variables: Automatic.).
  2092.  
  2093. 
  2094. File: make,  Node: Special Targets,  Next: Multiple Targets,  Prev: Empty Targets,  Up: Rules
  2095.  
  2096. 4.9 Special Built-in Target Names
  2097. =================================
  2098.  
  2099. Certain names have special meanings if they appear as targets.
  2100.  
  2101. `.PHONY'
  2102.      The prerequisites of the special target `.PHONY' are considered to
  2103.      be phony targets.  When it is time to consider such a target,
  2104.      `make' will run its commands unconditionally, regardless of
  2105.      whether a file with that name exists or what its last-modification
  2106.      time is.  *Note Phony Targets: Phony Targets.
  2107.  
  2108. `.SUFFIXES'
  2109.      The prerequisites of the special target `.SUFFIXES' are the list
  2110.      of suffixes to be used in checking for suffix rules.  *Note
  2111.      Old-Fashioned Suffix Rules: Suffix Rules.
  2112.  
  2113. `.DEFAULT'
  2114.      The commands specified for `.DEFAULT' are used for any target for
  2115.      which no rules are found (either explicit rules or implicit rules).
  2116.      *Note Last Resort::.  If `.DEFAULT' commands are specified, every
  2117.      file mentioned as a prerequisite, but not as a target in a rule,
  2118.      will have these commands executed on its behalf.  *Note Implicit
  2119.      Rule Search Algorithm: Implicit Rule Search.
  2120.  
  2121. `.PRECIOUS'
  2122.      The targets which `.PRECIOUS' depends on are given the following
  2123.      special treatment: if `make' is killed or interrupted during the
  2124.      execution of their commands, the target is not deleted.  *Note
  2125.      Interrupting or Killing `make': Interrupts.  Also, if the target
  2126.      is an intermediate file, it will not be deleted after it is no
  2127.      longer needed, as is normally done.  *Note Chains of Implicit
  2128.      Rules: Chained Rules.  In this latter respect it overlaps with the
  2129.      `.SECONDARY' special target.
  2130.  
  2131.      You can also list the target pattern of an implicit rule (such as
  2132.      `%.o') as a prerequisite file of the special target `.PRECIOUS' to
  2133.      preserve intermediate files created by rules whose target patterns
  2134.      match that file's name.
  2135.  
  2136. `.INTERMEDIATE'
  2137.      The targets which `.INTERMEDIATE' depends on are treated as
  2138.      intermediate files.  *Note Chains of Implicit Rules: Chained Rules.
  2139.      `.INTERMEDIATE' with no prerequisites has no effect.
  2140.  
  2141. `.SECONDARY'
  2142.      The targets which `.SECONDARY' depends on are treated as
  2143.      intermediate files, except that they are never automatically
  2144.      deleted.  *Note Chains of Implicit Rules: Chained Rules.
  2145.  
  2146.      `.SECONDARY' with no prerequisites causes all targets to be treated
  2147.      as secondary (i.e., no target is removed because it is considered
  2148.      intermediate).
  2149.  
  2150. `.DELETE_ON_ERROR'
  2151.      If `.DELETE_ON_ERROR' is mentioned as a target anywhere in the
  2152.      makefile, then `make' will delete the target of a rule if it has
  2153.      changed and its commands exit with a nonzero exit status, just as
  2154.      it does when it receives a signal.  *Note Errors in Commands:
  2155.      Errors.
  2156.  
  2157. `.IGNORE'
  2158.      If you specify prerequisites for `.IGNORE', then `make' will
  2159.      ignore errors in execution of the commands run for those particular
  2160.      files.  The commands for `.IGNORE' are not meaningful.
  2161.  
  2162.      If mentioned as a target with no prerequisites, `.IGNORE' says to
  2163.      ignore errors in execution of commands for all files.  This usage
  2164.      of `.IGNORE' is supported only for historical compatibility.  Since
  2165.      this affects every command in the makefile, it is not very useful;
  2166.      we recommend you use the more selective ways to ignore errors in
  2167.      specific commands.  *Note Errors in Commands: Errors.
  2168.  
  2169. `.LOW_RESOLUTION_TIME'
  2170.      If you specify prerequisites for `.LOW_RESOLUTION_TIME', `make'
  2171.      assumes that these files are created by commands that generate low
  2172.      resolution time stamps.  The commands for `.LOW_RESOLUTION_TIME'
  2173.      are not meaningful.
  2174.  
  2175.      The high resolution file time stamps of many modern hosts lessen
  2176.      the chance of `make' incorrectly concluding that a file is up to
  2177.      date.  Unfortunately, these hosts provide no way to set a high
  2178.      resolution file time stamp, so commands like `cp -p' that
  2179.      explicitly set a file's time stamp must discard its subsecond
  2180.      part.  If a file is created by such a command, you should list it
  2181.      as a prerequisite of `.LOW_RESOLUTION_TIME' so that `make' does
  2182.      not mistakenly conclude that the file is out of date.  For example:
  2183.  
  2184.           .LOW_RESOLUTION_TIME: dst
  2185.           dst: src
  2186.                   cp -p src dst
  2187.  
  2188.      Since `cp -p' discards the subsecond part of `src''s time stamp,
  2189.      `dst' is typically slightly older than `src' even when it is up to
  2190.      date.  The `.LOW_RESOLUTION_TIME' line causes `make' to consider
  2191.      `dst' to be up to date if its time stamp is at the start of the
  2192.      same second that `src''s time stamp is in.
  2193.  
  2194.      Due to a limitation of the archive format, archive member time
  2195.      stamps are always low resolution.  You need not list archive
  2196.      members as prerequisites of `.LOW_RESOLUTION_TIME', as `make' does
  2197.      this automatically.
  2198.  
  2199. `.SILENT'
  2200.      If you specify prerequisites for `.SILENT', then `make' will not
  2201.      print the commands to remake those particular files before
  2202.      executing them.  The commands for `.SILENT' are not meaningful.
  2203.  
  2204.      If mentioned as a target with no prerequisites, `.SILENT' says not
  2205.      to print any commands before executing them.  This usage of
  2206.      `.SILENT' is supported only for historical compatibility.  We
  2207.      recommend you use the more selective ways to silence specific
  2208.      commands.  *Note Command Echoing: Echoing.  If you want to silence
  2209.      all commands for a particular run of `make', use the `-s' or
  2210.      `--silent' option (*note Options Summary::).
  2211.  
  2212. `.EXPORT_ALL_VARIABLES'
  2213.      Simply by being mentioned as a target, this tells `make' to export
  2214.      all variables to child processes by default.  *Note Communicating
  2215.      Variables to a Sub-`make': Variables/Recursion.
  2216.  
  2217. `.NOTPARALLEL'
  2218.      If `.NOTPARALLEL' is mentioned as a target, then this invocation of
  2219.      `make' will be run serially, even if the `-j' option is given.
  2220.      Any recursively invoked `make' command will still be run in
  2221.      parallel (unless its makefile contains this target).  Any
  2222.      prerequisites on this target are ignored.
  2223.  
  2224.    Any defined implicit rule suffix also counts as a special target if
  2225. it appears as a target, and so does the concatenation of two suffixes,
  2226. such as `.c.o'.  These targets are suffix rules, an obsolete way of
  2227. defining implicit rules (but a way still widely used).  In principle,
  2228. any target name could be special in this way if you break it in two and
  2229. add both pieces to the suffix list.  In practice, suffixes normally
  2230. begin with `.', so these special target names also begin with `.'.
  2231. *Note Old-Fashioned Suffix Rules: Suffix Rules.
  2232.  
  2233. 
  2234. File: make,  Node: Multiple Targets,  Next: Multiple Rules,  Prev: Special Targets,  Up: Rules
  2235.  
  2236. 4.10 Multiple Targets in a Rule
  2237. ===============================
  2238.  
  2239. A rule with multiple targets is equivalent to writing many rules, each
  2240. with one target, and all identical aside from that.  The same commands
  2241. apply to all the targets, but their effects may vary because you can
  2242. substitute the actual target name into the command using `$@'.  The
  2243. rule contributes the same prerequisites to all the targets also.
  2244.  
  2245.    This is useful in two cases.
  2246.  
  2247.    * You want just prerequisites, no commands.  For example:
  2248.  
  2249.           kbd.o command.o files.o: command.h
  2250.  
  2251.      gives an additional prerequisite to each of the three object files
  2252.      mentioned.
  2253.  
  2254.    * Similar commands work for all the targets.  The commands do not
  2255.      need to be absolutely identical, since the automatic variable `$@'
  2256.      can be used to substitute the particular target to be remade into
  2257.      the commands (*note Automatic Variables: Automatic.).  For example:
  2258.  
  2259.           bigoutput littleoutput : text.g
  2260.                   generate text.g -$(subst output,,$@) > $@
  2261.      
  2262.      is equivalent to
  2263.  
  2264.           bigoutput : text.g
  2265.                   generate text.g -big > bigoutput
  2266.           littleoutput : text.g
  2267.                   generate text.g -little > littleoutput
  2268.  
  2269.      Here we assume the hypothetical program `generate' makes two types
  2270.      of output, one if given `-big' and one if given `-little'.  *Note
  2271.      Functions for String Substitution and Analysis: Text Functions,
  2272.      for an explanation of the `subst' function.
  2273.  
  2274.    Suppose you would like to vary the prerequisites according to the
  2275. target, much as the variable `$@' allows you to vary the commands.  You
  2276. cannot do this with multiple targets in an ordinary rule, but you can
  2277. do it with a "static pattern rule".  *Note Static Pattern Rules: Static
  2278. Pattern.
  2279.  
  2280. 
  2281. File: make,  Node: Multiple Rules,  Next: Static Pattern,  Prev: Multiple Targets,  Up: Rules
  2282.  
  2283. 4.11 Multiple Rules for One Target
  2284. ==================================
  2285.  
  2286. One file can be the target of several rules.  All the prerequisites
  2287. mentioned in all the rules are merged into one list of prerequisites for
  2288. the target.  If the target is older than any prerequisite from any rule,
  2289. the commands are executed.
  2290.  
  2291.    There can only be one set of commands to be executed for a file.  If
  2292. more than one rule gives commands for the same file, `make' uses the
  2293. last set given and prints an error message.  (As a special case, if the
  2294. file's name begins with a dot, no error message is printed.  This odd
  2295. behavior is only for compatibility with other implementations of
  2296. `make'... you should avoid using it).  Occasionally it is useful to
  2297. have the same target invoke multiple commands which are defined in
  2298. different parts of your makefile; you can use "double-colon rules"
  2299. (*note Double-Colon::) for this.
  2300.  
  2301.    An extra rule with just prerequisites can be used to give a few extra
  2302. prerequisites to many files at once.  For example, makefiles often have
  2303. a variable, such as `objects', containing a list of all the compiler
  2304. output files in the system being made.  An easy way to say that all of
  2305. them must be recompiled if `config.h' changes is to write the following:
  2306.  
  2307.      objects = foo.o bar.o
  2308.      foo.o : defs.h
  2309.      bar.o : defs.h test.h
  2310.      $(objects) : config.h
  2311.  
  2312.    This could be inserted or taken out without changing the rules that
  2313. really specify how to make the object files, making it a convenient
  2314. form to use if you wish to add the additional prerequisite
  2315. intermittently.
  2316.  
  2317.    Another wrinkle is that the additional prerequisites could be
  2318. specified with a variable that you set with a command argument to `make'
  2319. (*note Overriding Variables: Overriding.).  For example,
  2320.  
  2321.      extradeps=
  2322.      $(objects) : $(extradeps)
  2323.  
  2324. means that the command `make extradeps=foo.h' will consider `foo.h' as
  2325. a prerequisite of each object file, but plain `make' will not.
  2326.  
  2327.    If none of the explicit rules for a target has commands, then `make'
  2328. searches for an applicable implicit rule to find some commands *note
  2329. Using Implicit Rules: Implicit Rules.).
  2330.  
  2331. 
  2332. File: make,  Node: Static Pattern,  Next: Double-Colon,  Prev: Multiple Rules,  Up: Rules
  2333.  
  2334. 4.12 Static Pattern Rules
  2335. =========================
  2336.  
  2337. "Static pattern rules" are rules which specify multiple targets and
  2338. construct the prerequisite names for each target based on the target
  2339. name.  They are more general than ordinary rules with multiple targets
  2340. because the targets do not have to have identical prerequisites.  Their
  2341. prerequisites must be _analogous_, but not necessarily _identical_.
  2342.  
  2343. * Menu:
  2344.  
  2345. * Static Usage::                The syntax of static pattern rules.
  2346. * Static versus Implicit::      When are they better than implicit rules?
  2347.  
  2348. 
  2349. File: make,  Node: Static Usage,  Next: Static versus Implicit,  Prev: Static Pattern,  Up: Static Pattern
  2350.  
  2351. 4.12.1 Syntax of Static Pattern Rules
  2352. -------------------------------------
  2353.  
  2354. Here is the syntax of a static pattern rule:
  2355.  
  2356.      TARGETS ...: TARGET-PATTERN: PREREQ-PATTERNS ...
  2357.              COMMANDS
  2358.              ...
  2359.  
  2360. The TARGETS list specifies the targets that the rule applies to.  The
  2361. targets can contain wildcard characters, just like the targets of
  2362. ordinary rules (*note Using Wildcard Characters in File Names:
  2363. Wildcards.).
  2364.  
  2365.    The TARGET-PATTERN and PREREQ-PATTERNS say how to compute the
  2366. prerequisites of each target.  Each target is matched against the
  2367. TARGET-PATTERN to extract a part of the target name, called the "stem".
  2368. This stem is substituted into each of the PREREQ-PATTERNS to make the
  2369. prerequisite names (one from each PREREQ-PATTERN).
  2370.  
  2371.    Each pattern normally contains the character `%' just once.  When the
  2372. TARGET-PATTERN matches a target, the `%' can match any part of the
  2373. target name; this part is called the "stem".  The rest of the pattern
  2374. must match exactly.  For example, the target `foo.o' matches the
  2375. pattern `%.o', with `foo' as the stem.  The targets `foo.c' and
  2376. `foo.out' do not match that pattern.
  2377.  
  2378.    The prerequisite names for each target are made by substituting the
  2379. stem for the `%' in each prerequisite pattern.  For example, if one
  2380. prerequisite pattern is `%.c', then substitution of the stem `foo'
  2381. gives the prerequisite name `foo.c'.  It is legitimate to write a
  2382. prerequisite pattern that does not contain `%'; then this prerequisite
  2383. is the same for all targets.
  2384.  
  2385.    `%' characters in pattern rules can be quoted with preceding
  2386. backslashes (`\').  Backslashes that would otherwise quote `%'
  2387. characters can be quoted with more backslashes.  Backslashes that quote
  2388. `%' characters or other backslashes are removed from the pattern before
  2389. it is compared to file names or has a stem substituted into it.
  2390. Backslashes that are not in danger of quoting `%' characters go
  2391. unmolested.  For example, the pattern `the\%weird\\%pattern\\' has
  2392. `the%weird\' preceding the operative `%' character, and `pattern\\'
  2393. following it.  The final two backslashes are left alone because they
  2394. cannot affect any `%' character.
  2395.  
  2396.    Here is an example, which compiles each of `foo.o' and `bar.o' from
  2397. the corresponding `.c' file:
  2398.  
  2399.      objects = foo.o bar.o
  2400.  
  2401.      all: $(objects)
  2402.  
  2403.      $(objects): %.o: %.c
  2404.              $(CC) -c $(CFLAGS) $< -o $@
  2405.  
  2406. Here `$<' is the automatic variable that holds the name of the
  2407. prerequisite and `$@' is the automatic variable that holds the name of
  2408. the target; see *Note Automatic Variables: Automatic.
  2409.  
  2410.    Each target specified must match the target pattern; a warning is
  2411. issued for each target that does not.  If you have a list of files,
  2412. only some of which will match the pattern, you can use the `filter'
  2413. function to remove nonmatching file names (*note Functions for String
  2414. Substitution and Analysis: Text Functions.):
  2415.  
  2416.      files = foo.elc bar.o lose.o
  2417.  
  2418.      $(filter %.o,$(files)): %.o: %.c
  2419.              $(CC) -c $(CFLAGS) $< -o $@
  2420.      $(filter %.elc,$(files)): %.elc: %.el
  2421.              emacs -f batch-byte-compile $<
  2422.  
  2423. In this example the result of `$(filter %.o,$(files))' is `bar.o
  2424. lose.o', and the first static pattern rule causes each of these object
  2425. files to be updated by compiling the corresponding C source file.  The
  2426. result of `$(filter %.elc,$(files))' is `foo.elc', so that file is made
  2427. from `foo.el'.
  2428.  
  2429.    Another example shows how to use `$*' in static pattern rules: 
  2430.  
  2431.      bigoutput littleoutput : %output : text.g
  2432.              generate text.g -$* > $@
  2433.  
  2434. When the `generate' command is run, `$*' will expand to the stem,
  2435. either `big' or `little'.
  2436.  
  2437. 
  2438. File: make,  Node: Static versus Implicit,  Prev: Static Usage,  Up: Static Pattern
  2439.  
  2440. 4.12.2 Static Pattern Rules versus Implicit Rules
  2441. -------------------------------------------------
  2442.  
  2443. A static pattern rule has much in common with an implicit rule defined
  2444. as a pattern rule (*note Defining and Redefining Pattern Rules: Pattern
  2445. Rules.).  Both have a pattern for the target and patterns for
  2446. constructing the names of prerequisites.  The difference is in how
  2447. `make' decides _when_ the rule applies.
  2448.  
  2449.    An implicit rule _can_ apply to any target that matches its pattern,
  2450. but it _does_ apply only when the target has no commands otherwise
  2451. specified, and only when the prerequisites can be found.  If more than
  2452. one implicit rule appears applicable, only one applies; the choice
  2453. depends on the order of rules.
  2454.  
  2455.    By contrast, a static pattern rule applies to the precise list of
  2456. targets that you specify in the rule.  It cannot apply to any other
  2457. target and it invariably does apply to each of the targets specified.
  2458. If two conflicting rules apply, and both have commands, that's an error.
  2459.  
  2460.    The static pattern rule can be better than an implicit rule for these
  2461. reasons:
  2462.  
  2463.    * You may wish to override the usual implicit rule for a few files
  2464.      whose names cannot be categorized syntactically but can be given
  2465.      in an explicit list.
  2466.  
  2467.    * If you cannot be sure of the precise contents of the directories
  2468.      you are using, you may not be sure which other irrelevant files
  2469.      might lead `make' to use the wrong implicit rule.  The choice
  2470.      might depend on the order in which the implicit rule search is
  2471.      done.  With static pattern rules, there is no uncertainty: each
  2472.      rule applies to precisely the targets specified.
  2473.  
  2474. 
  2475. File: make,  Node: Double-Colon,  Next: Automatic Prerequisites,  Prev: Static Pattern,  Up: Rules
  2476.  
  2477. 4.13 Double-Colon Rules
  2478. =======================
  2479.  
  2480. "Double-colon" rules are rules written with `::' instead of `:' after
  2481. the target names.  They are handled differently from ordinary rules
  2482. when the same target appears in more than one rule.
  2483.  
  2484.    When a target appears in multiple rules, all the rules must be the
  2485. same type: all ordinary, or all double-colon.  If they are
  2486. double-colon, each of them is independent of the others.  Each
  2487. double-colon rule's commands are executed if the target is older than
  2488. any prerequisites of that rule.  If there are no prerequisites for that
  2489. rule, its commands are always executed (even if the target already
  2490. exists).  This can result in executing none, any, or all of the
  2491. double-colon rules.
  2492.  
  2493.    Double-colon rules with the same target are in fact completely
  2494. separate from one another.  Each double-colon rule is processed
  2495. individually, just as rules with different targets are processed.
  2496.  
  2497.    The double-colon rules for a target are executed in the order they
  2498. appear in the makefile.  However, the cases where double-colon rules
  2499. really make sense are those where the order of executing the commands
  2500. would not matter.
  2501.  
  2502.    Double-colon rules are somewhat obscure and not often very useful;
  2503. they provide a mechanism for cases in which the method used to update a
  2504. target differs depending on which prerequisite files caused the update,
  2505. and such cases are rare.
  2506.  
  2507.    Each double-colon rule should specify commands; if it does not, an
  2508. implicit rule will be used if one applies.  *Note Using Implicit Rules:
  2509. Implicit Rules.
  2510.  
  2511. 
  2512. File: make,  Node: Automatic Prerequisites,  Prev: Double-Colon,  Up: Rules
  2513.  
  2514. 4.14 Generating Prerequisites Automatically
  2515. ===========================================
  2516.  
  2517. In the makefile for a program, many of the rules you need to write often
  2518. say only that some object file depends on some header file.  For
  2519. example, if `main.c' uses `defs.h' via an `#include', you would write:
  2520.  
  2521.      main.o: defs.h
  2522.  
  2523. You need this rule so that `make' knows that it must remake `main.o'
  2524. whenever `defs.h' changes.  You can see that for a large program you
  2525. would have to write dozens of such rules in your makefile.  And, you
  2526. must always be very careful to update the makefile every time you add
  2527. or remove an `#include'.  
  2528.  
  2529.    To avoid this hassle, most modern C compilers can write these rules
  2530. for you, by looking at the `#include' lines in the source files.
  2531. Usually this is done with the `-M' option to the compiler.  For
  2532. example, the command:
  2533.  
  2534.      cc -M main.c
  2535.  
  2536. generates the output:
  2537.  
  2538.      main.o : main.c defs.h
  2539.  
  2540. Thus you no longer have to write all those rules yourself.  The
  2541. compiler will do it for you.
  2542.  
  2543.    Note that such a prerequisite constitutes mentioning `main.o' in a
  2544. makefile, so it can never be considered an intermediate file by implicit
  2545. rule search.  This means that `make' won't ever remove the file after
  2546. using it; *note Chains of Implicit Rules: Chained Rules.
  2547.  
  2548.    With old `make' programs, it was traditional practice to use this
  2549. compiler feature to generate prerequisites on demand with a command like
  2550. `make depend'.  That command would create a file `depend' containing
  2551. all the automatically-generated prerequisites; then the makefile could
  2552. use `include' to read them in (*note Include::).
  2553.  
  2554.    In GNU `make', the feature of remaking makefiles makes this practice
  2555. obsolete--you need never tell `make' explicitly to regenerate the
  2556. prerequisites, because it always regenerates any makefile that is out
  2557. of date.  *Note Remaking Makefiles::.
  2558.  
  2559.    The practice we recommend for automatic prerequisite generation is
  2560. to have one makefile corresponding to each source file.  For each
  2561. source file `NAME.c' there is a makefile `NAME.d' which lists what
  2562. files the object file `NAME.o' depends on.  That way only the source
  2563. files that have changed need to be rescanned to produce the new
  2564. prerequisites.
  2565.  
  2566.    Here is the pattern rule to generate a file of prerequisites (i.e.,
  2567. a makefile) called `NAME.d' from a C source file called `NAME.c':
  2568.  
  2569.      %.d: %.c
  2570.  
  2571.               $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
  2572.               sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
  2573.               rm -f $@.$$$$
  2574.  
  2575. *Note Pattern Rules::, for information on defining pattern rules.  The
  2576. `-e' flag to the shell causes it to exit immediately if the `$(CC)'
  2577. command (or any other command) fails (exits with a nonzero status).  
  2578.  
  2579.    With the GNU C compiler, you may wish to use the `-MM' flag instead
  2580. of `-M'.  This omits prerequisites on system header files.  *Note
  2581. Options Controlling the Preprocessor: (gcc.info)Preprocessor Options,
  2582. for details.
  2583.  
  2584.    The purpose of the `sed' command is to translate (for example):
  2585.  
  2586.      main.o : main.c defs.h
  2587.  
  2588. into:
  2589.  
  2590.      main.o main.d : main.c defs.h
  2591.  
  2592. This makes each `.d' file depend on all the source and header files
  2593. that the corresponding `.o' file depends on.  `make' then knows it must
  2594. regenerate the prerequisites whenever any of the source or header files
  2595. changes.
  2596.  
  2597.    Once you've defined the rule to remake the `.d' files, you then use
  2598. the `include' directive to read them all in.  *Note Include::.  For
  2599. example:
  2600.  
  2601.      sources = foo.c bar.c
  2602.  
  2603.      include $(sources:.c=.d)
  2604.  
  2605. (This example uses a substitution variable reference to translate the
  2606. list of source files `foo.c bar.c' into a list of prerequisite
  2607. makefiles, `foo.d bar.d'.  *Note Substitution Refs::, for full
  2608. information on substitution references.)  Since the `.d' files are
  2609. makefiles like any others, `make' will remake them as necessary with no
  2610. further work from you.  *Note Remaking Makefiles::.
  2611.  
  2612.    Note that the `.d' files contain target definitions; you should be
  2613. sure to place the `include' directive _after_ the first, default target
  2614. in your makefiles or run the risk of having a random object file become
  2615. the default target.  *Note How Make Works::.
  2616.  
  2617. 
  2618. File: make,  Node: Commands,  Next: Using Variables,  Prev: Rules,  Up: Top
  2619.  
  2620. 5 Writing the Commands in Rules
  2621. *******************************
  2622.  
  2623. The commands of a rule consist of shell command lines to be executed one
  2624. by one.  Each command line must start with a tab, except that the first
  2625. command line may be attached to the target-and-prerequisites line with a
  2626. semicolon in between.  Blank lines and lines of just comments may appear
  2627. among the command lines; they are ignored.  (But beware, an apparently
  2628. "blank" line that begins with a tab is _not_ blank!  It is an empty
  2629. command; *note Empty Commands::.)
  2630.  
  2631.    Users use many different shell programs, but commands in makefiles
  2632. are always interpreted by `/bin/sh' unless the makefile specifies
  2633. otherwise.  *Note Command Execution: Execution.
  2634.  
  2635.    The shell that is in use determines whether comments can be written
  2636. on command lines, and what syntax they use.  When the shell is
  2637. `/bin/sh', a `#' starts a comment that extends to the end of the line.
  2638. The `#' does not have to be at the beginning of a line.  Text on a line
  2639. before a `#' is not part of the comment.
  2640.  
  2641. * Menu:
  2642.  
  2643. * Echoing::                     How to control when commands are echoed.
  2644. * Execution::                   How commands are executed.
  2645. * Parallel::                    How commands can be executed in parallel.
  2646. * Errors::                      What happens after a command execution error.
  2647. * Interrupts::                  What happens when a command is interrupted.
  2648. * Recursion::                   Invoking `make' from makefiles.
  2649. * Sequences::                   Defining canned sequences of commands.
  2650. * Empty Commands::              Defining useful, do-nothing commands.
  2651.  
  2652. 
  2653. File: make,  Node: Echoing,  Next: Execution,  Prev: Commands,  Up: Commands
  2654.  
  2655. 5.1 Command Echoing
  2656. ===================
  2657.  
  2658. Normally `make' prints each command line before it is executed.  We
  2659. call this "echoing" because it gives the appearance that you are typing
  2660. the commands yourself.
  2661.  
  2662.    When a line starts with `@', the echoing of that line is suppressed.
  2663. The `@' is discarded before the command is passed to the shell.
  2664. Typically you would use this for a command whose only effect is to print
  2665. something, such as an `echo' command to indicate progress through the
  2666. makefile:
  2667.  
  2668.      @echo About to make distribution files
  2669.  
  2670.    When `make' is given the flag `-n' or `--just-print' it only echoes
  2671. commands, it won't execute them.  *Note Summary of Options: Options
  2672. Summary.  In this case and only this case, even the commands starting
  2673. with `@' are printed.  This flag is useful for finding out which
  2674. commands `make' thinks are necessary without actually doing them.
  2675.  
  2676.    The `-s' or `--silent' flag to `make' prevents all echoing, as if
  2677. all commands started with `@'.  A rule in the makefile for the special
  2678. target `.SILENT' without prerequisites has the same effect (*note
  2679. Special Built-in Target Names: Special Targets.).  `.SILENT' is
  2680. essentially obsolete since `@' is more flexible.
  2681.  
  2682. 
  2683. File: make,  Node: Execution,  Next: Parallel,  Prev: Echoing,  Up: Commands
  2684.  
  2685. 5.2 Command Execution
  2686. =====================
  2687.  
  2688. When it is time to execute commands to update a target, they are
  2689. executed by making a new subshell for each line.  (In practice, `make'
  2690. may take shortcuts that do not affect the results.)
  2691.  
  2692.    *Please note:* this implies that shell commands such as `cd' that
  2693. set variables local to each process will not affect the following
  2694. command lines. (1)  If you want to use `cd' to affect the next command,
  2695. put the two on a single line with a semicolon between them.  Then
  2696. `make' will consider them a single command and pass them, together, to
  2697. a shell which will execute them in sequence.  For example:
  2698.  
  2699.      foo : bar/lose
  2700.              cd bar; gobble lose > ../foo
  2701.  
  2702.    If you would like to split a single shell command into multiple
  2703. lines of text, you must use a backslash at the end of all but the last
  2704. subline.  Such a sequence of lines is combined into a single line, by
  2705. deleting the backslash-newline sequences, before passing it to the
  2706. shell.  Thus, the following is equivalent to the preceding example:
  2707.  
  2708.      foo : bar/lose
  2709.              cd bar;  \
  2710.              gobble lose > ../foo
  2711.  
  2712.    The program used as the shell is taken from the variable `SHELL'.
  2713. By default, the program `/bin/sh' is used.
  2714.  
  2715.    On MS-DOS, if `SHELL' is not set, the value of the variable
  2716. `COMSPEC' (which is always set) is used instead.
  2717.  
  2718.    The processing of lines that set the variable `SHELL' in Makefiles
  2719. is different on MS-DOS.  The stock shell, `command.com', is
  2720. ridiculously limited in its functionality and many users of `make' tend
  2721. to install a replacement shell.  Therefore, on MS-DOS, `make' examines
  2722. the value of `SHELL', and changes its behavior based on whether it
  2723. points to a Unix-style or DOS-style shell.  This allows reasonable
  2724. functionality even if `SHELL' points to `command.com'.
  2725.  
  2726.    If `SHELL' points to a Unix-style shell, `make' on MS-DOS
  2727. additionally checks whether that shell can indeed be found; if not, it
  2728. ignores the line that sets `SHELL'.  In MS-DOS, GNU `make' searches for
  2729. the shell in the following places:
  2730.  
  2731.   1. In the precise place pointed to by the value of `SHELL'.  For
  2732.      example, if the makefile specifies `SHELL = /bin/sh', `make' will
  2733.      look in the directory `/bin' on the current drive.
  2734.  
  2735.   2. In the current directory.
  2736.  
  2737.   3. In each of the directories in the `PATH' variable, in order.
  2738.  
  2739.  
  2740.    In every directory it examines, `make' will first look for the
  2741. specific file (`sh' in the example above).  If this is not found, it
  2742. will also look in that directory for that file with one of the known
  2743. extensions which identify executable files.  For example `.exe',
  2744. `.com', `.bat', `.btm', `.sh', and some others.
  2745.  
  2746.    If any of these attempts is successful, the value of `SHELL' will be
  2747. set to the full pathname of the shell as found.  However, if none of
  2748. these is found, the value of `SHELL' will not be changed, and thus the
  2749. line that sets it will be effectively ignored.  This is so `make' will
  2750. only support features specific to a Unix-style shell if such a shell is
  2751. actually installed on the system where `make' runs.
  2752.  
  2753.    Note that this extended search for the shell is limited to the cases
  2754. where `SHELL' is set from the Makefile; if it is set in the environment
  2755. or command line, you are expected to set it to the full pathname of the
  2756. shell, exactly as things are on Unix.
  2757.  
  2758.    The effect of the above DOS-specific processing is that a Makefile
  2759. that says `SHELL = /bin/sh' (as many Unix makefiles do), will work on
  2760. MS-DOS unaltered if you have e.g. `sh.exe' installed in some directory
  2761. along your `PATH'.
  2762.  
  2763.    Unlike most variables, the variable `SHELL' is never set from the
  2764. environment.  This is because the `SHELL' environment variable is used
  2765. to specify your personal choice of shell program for interactive use.
  2766. It would be very bad for personal choices like this to affect the
  2767. functioning of makefiles.  *Note Variables from the Environment:
  2768. Environment.  However, on MS-DOS and MS-Windows the value of `SHELL' in
  2769. the environment *is* used, since on those systems most users do not set
  2770. this variable, and therefore it is most likely set specifically to be
  2771. used by `make'.  On MS-DOS, if the setting of `SHELL' is not suitable
  2772. for `make', you can set the variable `MAKESHELL' to the shell that
  2773. `make' should use; this will override the value of `SHELL'.
  2774.  
  2775.    ---------- Footnotes ----------
  2776.  
  2777.    (1) On MS-DOS, the value of current working directory is *global*,
  2778. so changing it _will_ affect the following command lines on those
  2779. systems.
  2780.  
  2781. 
  2782. File: make,  Node: Parallel,  Next: Errors,  Prev: Execution,  Up: Commands
  2783.  
  2784. 5.3 Parallel Execution
  2785. ======================
  2786.  
  2787. GNU `make' knows how to execute several commands at once.  Normally,
  2788. `make' will execute only one command at a time, waiting for it to
  2789. finish before executing the next.  However, the `-j' or `--jobs' option
  2790. tells `make' to execute many commands simultaneously.
  2791.  
  2792.    On MS-DOS, the `-j' option has no effect, since that system doesn't
  2793. support multi-processing.
  2794.  
  2795.    If the `-j' option is followed by an integer, this is the number of
  2796. commands to execute at once; this is called the number of "job slots".
  2797. If there is nothing looking like an integer after the `-j' option,
  2798. there is no limit on the number of job slots.  The default number of job
  2799. slots is one, which means serial execution (one thing at a time).
  2800.  
  2801.    One unpleasant consequence of running several commands
  2802. simultaneously is that output generated by the commands appears
  2803. whenever each command sends it, so messages from different commands may
  2804. be interspersed.
  2805.  
  2806.    Another problem is that two processes cannot both take input from the
  2807. same device; so to make sure that only one command tries to take input
  2808. from the terminal at once, `make' will invalidate the standard input
  2809. streams of all but one running command.  This means that attempting to
  2810. read from standard input will usually be a fatal error (a `Broken pipe'
  2811. signal) for most child processes if there are several.  
  2812.  
  2813.    It is unpredictable which command will have a valid standard input
  2814. stream (which will come from the terminal, or wherever you redirect the
  2815. standard input of `make').  The first command run will always get it
  2816. first, and the first command started after that one finishes will get
  2817. it next, and so on.
  2818.  
  2819.    We will change how this aspect of `make' works if we find a better
  2820. alternative.  In the mean time, you should not rely on any command using
  2821. standard input at all if you are using the parallel execution feature;
  2822. but if you are not using this feature, then standard input works
  2823. normally in all commands.
  2824.  
  2825.    Finally, handling recursive `make' invocations raises issues.  For
  2826. more information on this, see *Note Communicating Options to a
  2827. Sub-`make': Options/Recursion.
  2828.  
  2829.    If a command fails (is killed by a signal or exits with a nonzero
  2830. status), and errors are not ignored for that command (*note Errors in
  2831. Commands: Errors.), the remaining command lines to remake the same
  2832. target will not be run.  If a command fails and the `-k' or
  2833. `--keep-going' option was not given (*note Summary of Options: Options
  2834. Summary.), `make' aborts execution.  If make terminates for any reason
  2835. (including a signal) with child processes running, it waits for them to
  2836. finish before actually exiting.
  2837.  
  2838.    When the system is heavily loaded, you will probably want to run
  2839. fewer jobs than when it is lightly loaded.  You can use the `-l' option
  2840. to tell `make' to limit the number of jobs to run at once, based on the
  2841. load average.  The `-l' or `--max-load' option is followed by a
  2842. floating-point number.  For example,
  2843.  
  2844.      -l 2.5
  2845.  
  2846. will not let `make' start more than one job if the load average is
  2847. above 2.5.  The `-l' option with no following number removes the load
  2848. limit, if one was given with a previous `-l' option.
  2849.  
  2850.    More precisely, when `make' goes to start up a job, and it already
  2851. has at least one job running, it checks the current load average; if it
  2852. is not lower than the limit given with `-l', `make' waits until the load
  2853. average goes below that limit, or until all the other jobs finish.
  2854.  
  2855.    By default, there is no load limit.
  2856.  
  2857. 
  2858. File: make,  Node: Errors,  Next: Interrupts,  Prev: Parallel,  Up: Commands
  2859.  
  2860. 5.4 Errors in Commands
  2861. ======================
  2862.  
  2863. After each shell command returns, `make' looks at its exit status.  If
  2864. the command completed successfully, the next command line is executed
  2865. in a new shell; after the last command line is finished, the rule is
  2866. finished.
  2867.  
  2868.    If there is an error (the exit status is nonzero), `make' gives up on
  2869. the current rule, and perhaps on all rules.
  2870.  
  2871.    Sometimes the failure of a certain command does not indicate a
  2872. problem.  For example, you may use the `mkdir' command to ensure that a
  2873. directory exists.  If the directory already exists, `mkdir' will report
  2874. an error, but you probably want `make' to continue regardless.
  2875.  
  2876.    To ignore errors in a command line, write a `-' at the beginning of
  2877. the line's text (after the initial tab).  The `-' is discarded before
  2878. the command is passed to the shell for execution.
  2879.  
  2880.    For example,
  2881.  
  2882.      clean:
  2883.              -rm -f *.o
  2884.  
  2885. This causes `rm' to continue even if it is unable to remove a file.
  2886.  
  2887.    When you run `make' with the `-i' or `--ignore-errors' flag, errors
  2888. are ignored in all commands of all rules.  A rule in the makefile for
  2889. the special target `.IGNORE' has the same effect, if there are no
  2890. prerequisites.  These ways of ignoring errors are obsolete because `-'
  2891. is more flexible.
  2892.  
  2893.    When errors are to be ignored, because of either a `-' or the `-i'
  2894. flag, `make' treats an error return just like success, except that it
  2895. prints out a message that tells you the status code the command exited
  2896. with, and says that the error has been ignored.
  2897.  
  2898.    When an error happens that `make' has not been told to ignore, it
  2899. implies that the current target cannot be correctly remade, and neither
  2900. can any other that depends on it either directly or indirectly.  No
  2901. further commands will be executed for these targets, since their
  2902. preconditions have not been achieved.
  2903.  
  2904.    Normally `make' gives up immediately in this circumstance, returning
  2905. a nonzero status.  However, if the `-k' or `--keep-going' flag is
  2906. specified, `make' continues to consider the other prerequisites of the
  2907. pending targets, remaking them if necessary, before it gives up and
  2908. returns nonzero status.  For example, after an error in compiling one
  2909. object file, `make -k' will continue compiling other object files even
  2910. though it already knows that linking them will be impossible.  *Note
  2911. Summary of Options: Options Summary.
  2912.  
  2913.    The usual behavior assumes that your purpose is to get the specified
  2914. targets up to date; once `make' learns that this is impossible, it
  2915. might as well report the failure immediately.  The `-k' option says
  2916. that the real purpose is to test as many of the changes made in the
  2917. program as possible, perhaps to find several independent problems so
  2918. that you can correct them all before the next attempt to compile.  This
  2919. is why Emacs' `compile' command passes the `-k' flag by default.  
  2920.  
  2921.    Usually when a command fails, if it has changed the target file at
  2922. all, the file is corrupted and cannot be used--or at least it is not
  2923. completely updated.  Yet the file's time stamp says that it is now up to
  2924. date, so the next time `make' runs, it will not try to update that
  2925. file.  The situation is just the same as when the command is killed by a
  2926. signal; *note Interrupts::.  So generally the right thing to do is to
  2927. delete the target file if the command fails after beginning to change
  2928. the file.  `make' will do this if `.DELETE_ON_ERROR' appears as a
  2929. target.  This is almost always what you want `make' to do, but it is
  2930. not historical practice; so for compatibility, you must explicitly
  2931. request it.
  2932.  
  2933. 
  2934. File: make,  Node: Interrupts,  Next: Recursion,  Prev: Errors,  Up: Commands
  2935.  
  2936. 5.5 Interrupting or Killing `make'
  2937. ==================================
  2938.  
  2939. If `make' gets a fatal signal while a command is executing, it may
  2940. delete the target file that the command was supposed to update.  This is
  2941. done if the target file's last-modification time has changed since
  2942. `make' first checked it.
  2943.  
  2944.    The purpose of deleting the target is to make sure that it is remade
  2945. from scratch when `make' is next run.  Why is this?  Suppose you type
  2946. `Ctrl-c' while a compiler is running, and it has begun to write an
  2947. object file `foo.o'.  The `Ctrl-c' kills the compiler, resulting in an
  2948. incomplete file whose last-modification time is newer than the source
  2949. file `foo.c'.  But `make' also receives the `Ctrl-c' signal and deletes
  2950. this incomplete file.  If `make' did not do this, the next invocation
  2951. of `make' would think that `foo.o' did not require updating--resulting
  2952. in a strange error message from the linker when it tries to link an
  2953. object file half of which is missing.
  2954.  
  2955.    You can prevent the deletion of a target file in this way by making
  2956. the special target `.PRECIOUS' depend on it.  Before remaking a target,
  2957. `make' checks to see whether it appears on the prerequisites of
  2958. `.PRECIOUS', and thereby decides whether the target should be deleted
  2959. if a signal happens.  Some reasons why you might do this are that the
  2960. target is updated in some atomic fashion, or exists only to record a
  2961. modification-time (its contents do not matter), or must exist at all
  2962. times to prevent other sorts of trouble.
  2963.  
  2964. 
  2965. File: make,  Node: Recursion,  Next: Sequences,  Prev: Interrupts,  Up: Commands
  2966.  
  2967. 5.6 Recursive Use of `make'
  2968. ===========================
  2969.  
  2970. Recursive use of `make' means using `make' as a command in a makefile.
  2971. This technique is useful when you want separate makefiles for various
  2972. subsystems that compose a larger system.  For example, suppose you have
  2973. a subdirectory `subdir' which has its own makefile, and you would like
  2974. the containing directory's makefile to run `make' on the subdirectory.
  2975. You can do it by writing this:
  2976.  
  2977.      subsystem:
  2978.              cd subdir && $(MAKE)
  2979.  
  2980. or, equivalently, this (*note Summary of Options: Options Summary.):
  2981.  
  2982.      subsystem:
  2983.              $(MAKE) -C subdir
  2984.    
  2985.    You can write recursive `make' commands just by copying this example,
  2986. but there are many things to know about how they work and why, and about
  2987. how the sub-`make' relates to the top-level `make'.  You may also find
  2988. it useful to declare targets that invoke recursive `make' commands as
  2989. `.PHONY' (for more discussion on when this is useful, see *Note Phony
  2990. Targets::).
  2991.  
  2992.    For your convenience, GNU `make' sets the variable `CURDIR' to the
  2993. pathname of the current working directory for you.  If `-C' is in
  2994. effect, it will contain the path of the new directory, not the
  2995. original.  The value has the same precedence it would have if it were
  2996. set in the makefile (by default, an environment variable `CURDIR' will
  2997. not override this value).  Note that setting this variable has no
  2998. effect on the operation of `make'
  2999.  
  3000. * Menu:
  3001.  
  3002. * MAKE Variable::               The special effects of using `$(MAKE)'.
  3003. * Variables/Recursion::         How to communicate variables to a sub-`make'.
  3004. * Options/Recursion::           How to communicate options to a sub-`make'.
  3005. * -w Option::                   How the `-w' or `--print-directory' option
  3006.                                   helps debug use of recursive `make' commands.
  3007.  
  3008. 
  3009. File: make,  Node: MAKE Variable,  Next: Variables/Recursion,  Prev: Recursion,  Up: Recursion
  3010.  
  3011. 5.6.1 How the `MAKE' Variable Works
  3012. -----------------------------------
  3013.  
  3014. Recursive `make' commands should always use the variable `MAKE', not
  3015. the explicit command name `make', as shown here:
  3016.  
  3017.      subsystem:
  3018.              cd subdir && $(MAKE)
  3019.  
  3020.    The value of this variable is the file name with which `make' was
  3021. invoked.  If this file name was `/bin/make', then the command executed
  3022. is `cd subdir && /bin/make'.  If you use a special version of `make' to
  3023. run the top-level makefile, the same special version will be executed
  3024. for recursive invocations.  
  3025.  
  3026.    As a special feature, using the variable `MAKE' in the commands of a
  3027. rule alters the effects of the `-t' (`--touch'), `-n' (`--just-print'),
  3028. or `-q' (`--question') option.  Using the `MAKE' variable has the same
  3029. effect as using a `+' character at the beginning of the command line.
  3030. *Note Instead of Executing the Commands: Instead of Execution.
  3031.  
  3032.    Consider the command `make -t' in the above example.  (The `-t'
  3033. option marks targets as up to date without actually running any
  3034. commands; see *Note Instead of Execution::.)  Following the usual
  3035. definition of `-t', a `make -t' command in the example would create a
  3036. file named `subsystem' and do nothing else.  What you really want it to
  3037. do is run `cd subdir && make -t'; but that would require executing the
  3038. command, and `-t' says not to execute commands.  
  3039.  
  3040.    The special feature makes this do what you want: whenever a command
  3041. line of a rule contains the variable `MAKE', the flags `-t', `-n' and
  3042. `-q' do not apply to that line.  Command lines containing `MAKE' are
  3043. executed normally despite the presence of a flag that causes most
  3044. commands not to be run.  The usual `MAKEFLAGS' mechanism passes the
  3045. flags to the sub-`make' (*note Communicating Options to a Sub-`make':
  3046. Options/Recursion.), so your request to touch the files, or print the
  3047. commands, is propagated to the subsystem.
  3048.  
  3049. 
  3050. File: make,  Node: Variables/Recursion,  Next: Options/Recursion,  Prev: MAKE Variable,  Up: Recursion
  3051.  
  3052. 5.6.2 Communicating Variables to a Sub-`make'
  3053. ---------------------------------------------
  3054.  
  3055. Variable values of the top-level `make' can be passed to the sub-`make'
  3056. through the environment by explicit request.  These variables are
  3057. defined in the sub-`make' as defaults, but do not override what is
  3058. specified in the makefile used by the sub-`make' makefile unless you
  3059. use the `-e' switch (*note Summary of Options: Options Summary.).
  3060.  
  3061.    To pass down, or "export", a variable, `make' adds the variable and
  3062. its value to the environment for running each command.  The sub-`make',
  3063. in turn, uses the environment to initialize its table of variable
  3064. values.  *Note Variables from the Environment: Environment.
  3065.  
  3066.    Except by explicit request, `make' exports a variable only if it is
  3067. either defined in the environment initially or set on the command line,
  3068. and if its name consists only of letters, numbers, and underscores.
  3069. Some shells cannot cope with environment variable names consisting of
  3070. characters other than letters, numbers, and underscores.
  3071.  
  3072.    The special variables `SHELL' and `MAKEFLAGS' are always exported
  3073. (unless you unexport them).  `MAKEFILES' is exported if you set it to
  3074. anything.
  3075.  
  3076.    `make' automatically passes down variable values that were defined
  3077. on the command line, by putting them in the `MAKEFLAGS' variable.
  3078. *Note Options/Recursion::.
  3079.  
  3080.    Variables are _not_ normally passed down if they were created by
  3081. default by `make' (*note Variables Used by Implicit Rules: Implicit
  3082. Variables.).  The sub-`make' will define these for itself.
  3083.  
  3084.    If you want to export specific variables to a sub-`make', use the
  3085. `export' directive, like this:
  3086.  
  3087.      export VARIABLE ...
  3088.  
  3089. If you want to _prevent_ a variable from being exported, use the
  3090. `unexport' directive, like this:
  3091.  
  3092.      unexport VARIABLE ...
  3093.  
  3094. In both of these forms, the arguments to `export' and `unexport' are
  3095. expanded, and so could be variables or functions which expand to a
  3096. (list of) variable names to be (un)exported.
  3097.  
  3098.    As a convenience, you can define a variable and export it at the same
  3099. time by doing:
  3100.  
  3101.      export VARIABLE = value
  3102.  
  3103. has the same result as:
  3104.  
  3105.      VARIABLE = value
  3106.      export VARIABLE
  3107.  
  3108. and
  3109.  
  3110.      export VARIABLE := value
  3111.  
  3112. has the same result as:
  3113.  
  3114.      VARIABLE := value
  3115.      export VARIABLE
  3116.  
  3117.    Likewise,
  3118.  
  3119.      export VARIABLE += value
  3120.  
  3121. is just like:
  3122.  
  3123.      VARIABLE += value
  3124.      export VARIABLE
  3125.  
  3126. *Note Appending More Text to Variables: Appending.
  3127.  
  3128.    You may notice that the `export' and `unexport' directives work in
  3129. `make' in the same way they work in the shell, `sh'.
  3130.  
  3131.    If you want all variables to be exported by default, you can use
  3132. `export' by itself:
  3133.  
  3134.      export
  3135.  
  3136. This tells `make' that variables which are not explicitly mentioned in
  3137. an `export' or `unexport' directive should be exported.  Any variable
  3138. given in an `unexport' directive will still _not_ be exported.  If you
  3139. use `export' by itself to export variables by default, variables whose
  3140. names contain characters other than alphanumerics and underscores will
  3141. not be exported unless specifically mentioned in an `export' directive.
  3142.  
  3143.    The behavior elicited by an `export' directive by itself was the
  3144. default in older versions of GNU `make'.  If your makefiles depend on
  3145. this behavior and you want to be compatible with old versions of
  3146. `make', you can write a rule for the special target
  3147. `.EXPORT_ALL_VARIABLES' instead of using the `export' directive.  This
  3148. will be ignored by old `make's, while the `export' directive will cause
  3149. a syntax error.  
  3150.  
  3151.    Likewise, you can use `unexport' by itself to tell `make' _not_ to
  3152. export variables by default.  Since this is the default behavior, you
  3153. would only need to do this if `export' had been used by itself earlier
  3154. (in an included makefile, perhaps).  You *cannot* use `export' and
  3155. `unexport' by themselves to have variables exported for some commands
  3156. and not for others.  The last `export' or `unexport' directive that
  3157. appears by itself determines the behavior for the entire run of `make'.
  3158.  
  3159.    As a special feature, the variable `MAKELEVEL' is changed when it is
  3160. passed down from level to level.  This variable's value is a string
  3161. which is the depth of the level as a decimal number.  The value is `0'
  3162. for the top-level `make'; `1' for a sub-`make', `2' for a
  3163. sub-sub-`make', and so on.  The incrementation happens when `make' sets
  3164. up the environment for a command.
  3165.  
  3166.    The main use of `MAKELEVEL' is to test it in a conditional directive
  3167. (*note Conditional Parts of Makefiles: Conditionals.); this way you can
  3168. write a makefile that behaves one way if run recursively and another
  3169. way if run directly by you.
  3170.  
  3171.    You can use the variable `MAKEFILES' to cause all sub-`make'
  3172. commands to use additional makefiles.  The value of `MAKEFILES' is a
  3173. whitespace-separated list of file names.  This variable, if defined in
  3174. the outer-level makefile, is passed down through the environment; then
  3175. it serves as a list of extra makefiles for the sub-`make' to read
  3176. before the usual or specified ones.  *Note The Variable `MAKEFILES':
  3177. MAKEFILES Variable.
  3178.  
  3179. 
  3180. File: make,  Node: Options/Recursion,  Next: -w Option,  Prev: Variables/Recursion,  Up: Recursion
  3181.  
  3182. 5.6.3 Communicating Options to a Sub-`make'
  3183. -------------------------------------------
  3184.  
  3185. Flags such as `-s' and `-k' are passed automatically to the sub-`make'
  3186. through the variable `MAKEFLAGS'.  This variable is set up
  3187. automatically by `make' to contain the flag letters that `make'
  3188. received.  Thus, if you do `make -ks' then `MAKEFLAGS' gets the value
  3189. `ks'.
  3190.  
  3191.    As a consequence, every sub-`make' gets a value for `MAKEFLAGS' in
  3192. its environment.  In response, it takes the flags from that value and
  3193. processes them as if they had been given as arguments.  *Note Summary
  3194. of Options: Options Summary.
  3195.  
  3196.    Likewise variables defined on the command line are passed to the
  3197. sub-`make' through `MAKEFLAGS'.  Words in the value of `MAKEFLAGS' that
  3198. contain `=', `make' treats as variable definitions just as if they
  3199. appeared on the command line.  *Note Overriding Variables: Overriding.
  3200.  
  3201.    The options `-C', `-f', `-o', and `-W' are not put into `MAKEFLAGS';
  3202. these options are not passed down.
  3203.  
  3204.    The `-j' option is a special case (*note Parallel Execution:
  3205. Parallel.).  If you set it to some numeric value `N' and your operating
  3206. system supports it (most any UNIX system will; others typically won't),
  3207. the parent `make' and all the sub-`make's will communicate to ensure
  3208. that there are only `N' jobs running at the same time between them all.
  3209. Note that any job that is marked recursive (*note Instead of Executing
  3210. the Commands: Instead of Execution.)  doesn't count against the total
  3211. jobs (otherwise we could get `N' sub-`make's running and have no slots
  3212. left over for any real work!)
  3213.  
  3214.    If your operating system doesn't support the above communication,
  3215. then `-j 1' is always put into `MAKEFLAGS' instead of the value you
  3216. specified.  This is because if the `-j' option were passed down to
  3217. sub-`make's, you would get many more jobs running in parallel than you
  3218. asked for.  If you give `-j' with no numeric argument, meaning to run
  3219. as many jobs as possible in parallel, this is passed down, since
  3220. multiple infinities are no more than one.
  3221.  
  3222.    If you do not want to pass the other flags down, you must change the
  3223. value of `MAKEFLAGS', like this:
  3224.  
  3225.      subsystem:
  3226.              cd subdir && $(MAKE) MAKEFLAGS=
  3227.  
  3228.    The command line variable definitions really appear in the variable
  3229. `MAKEOVERRIDES', and `MAKEFLAGS' contains a reference to this variable.
  3230. If you do want to pass flags down normally, but don't want to pass
  3231. down the command line variable definitions, you can reset
  3232. `MAKEOVERRIDES' to empty, like this:
  3233.  
  3234.      MAKEOVERRIDES =
  3235.  
  3236. This is not usually useful to do.  However, some systems have a small
  3237. fixed limit on the size of the environment, and putting so much
  3238. information into the value of `MAKEFLAGS' can exceed it.  If you see
  3239. the error message `Arg list too long', this may be the problem.  (For
  3240. strict compliance with POSIX.2, changing `MAKEOVERRIDES' does not
  3241. affect `MAKEFLAGS' if the special target `.POSIX' appears in the
  3242. makefile.  You probably do not care about this.)
  3243.  
  3244.    A similar variable `MFLAGS' exists also, for historical
  3245. compatibility.  It has the same value as `MAKEFLAGS' except that it
  3246. does not contain the command line variable definitions, and it always
  3247. begins with a hyphen unless it is empty (`MAKEFLAGS' begins with a
  3248. hyphen only when it begins with an option that has no single-letter
  3249. version, such as `--warn-undefined-variables').  `MFLAGS' was
  3250. traditionally used explicitly in the recursive `make' command, like
  3251. this:
  3252.  
  3253.      subsystem:
  3254.              cd subdir && $(MAKE) $(MFLAGS)
  3255.  
  3256. but now `MAKEFLAGS' makes this usage redundant.  If you want your
  3257. makefiles to be compatible with old `make' programs, use this
  3258. technique; it will work fine with more modern `make' versions too.
  3259.  
  3260.    The `MAKEFLAGS' variable can also be useful if you want to have
  3261. certain options, such as `-k' (*note Summary of Options: Options
  3262. Summary.), set each time you run `make'.  You simply put a value for
  3263. `MAKEFLAGS' in your environment.  You can also set `MAKEFLAGS' in a
  3264. makefile, to specify additional flags that should also be in effect for
  3265. that makefile.  (Note that you cannot use `MFLAGS' this way.  That
  3266. variable is set only for compatibility; `make' does not interpret a
  3267. value you set for it in any way.)
  3268.  
  3269.    When `make' interprets the value of `MAKEFLAGS' (either from the
  3270. environment or from a makefile), it first prepends a hyphen if the value
  3271. does not already begin with one.  Then it chops the value into words
  3272. separated by blanks, and parses these words as if they were options
  3273. given on the command line (except that `-C', `-f', `-h', `-o', `-W',
  3274. and their long-named versions are ignored; and there is no error for an
  3275. invalid option).
  3276.  
  3277.    If you do put `MAKEFLAGS' in your environment, you should be sure not
  3278. to include any options that will drastically affect the actions of
  3279. `make' and undermine the purpose of makefiles and of `make' itself.
  3280. For instance, the `-t', `-n', and `-q' options, if put in one of these
  3281. variables, could have disastrous consequences and would certainly have
  3282. at least surprising and probably annoying effects.
  3283.  
  3284. 
  3285. File: make,  Node: -w Option,  Prev: Options/Recursion,  Up: Recursion
  3286.  
  3287. 5.6.4 The `--print-directory' Option
  3288. ------------------------------------
  3289.  
  3290. If you use several levels of recursive `make' invocations, the `-w' or
  3291. `--print-directory' option can make the output a lot easier to
  3292. understand by showing each directory as `make' starts processing it and
  3293. as `make' finishes processing it.  For example, if `make -w' is run in
  3294. the directory `/u/gnu/make', `make' will print a line of the form:
  3295.  
  3296.      make: Entering directory `/u/gnu/make'.
  3297.  
  3298. before doing anything else, and a line of the form:
  3299.  
  3300.      make: Leaving directory `/u/gnu/make'.
  3301.  
  3302. when processing is completed.
  3303.  
  3304.    Normally, you do not need to specify this option because `make' does
  3305. it for you: `-w' is turned on automatically when you use the `-C'
  3306. option, and in sub-`make's.  `make' will not automatically turn on `-w'
  3307. if you also use `-s', which says to be silent, or if you use
  3308. `--no-print-directory' to explicitly disable it.
  3309.  
  3310. 
  3311. File: make,  Node: Sequences,  Next: Empty Commands,  Prev: Recursion,  Up: Commands
  3312.  
  3313. 5.7 Defining Canned Command Sequences
  3314. =====================================
  3315.  
  3316. When the same sequence of commands is useful in making various targets,
  3317. you can define it as a canned sequence with the `define' directive, and
  3318. refer to the canned sequence from the rules for those targets.  The
  3319. canned sequence is actually a variable, so the name must not conflict
  3320. with other variable names.
  3321.  
  3322.    Here is an example of defining a canned sequence of commands:
  3323.  
  3324.      define run-yacc
  3325.      yacc $(firstword $^)
  3326.      mv y.tab.c $@
  3327.      endef
  3328.    
  3329. Here `run-yacc' is the name of the variable being defined; `endef'
  3330. marks the end of the definition; the lines in between are the commands.
  3331. The `define' directive does not expand variable references and
  3332. function calls in the canned sequence; the `$' characters, parentheses,
  3333. variable names, and so on, all become part of the value of the variable
  3334. you are defining.  *Note Defining Variables Verbatim: Defining, for a
  3335. complete explanation of `define'.
  3336.  
  3337.    The first command in this example runs Yacc on the first
  3338. prerequisite of whichever rule uses the canned sequence.  The output
  3339. file from Yacc is always named `y.tab.c'.  The second command moves the
  3340. output to the rule's target file name.
  3341.  
  3342.    To use the canned sequence, substitute the variable into the
  3343. commands of a rule.  You can substitute it like any other variable
  3344. (*note Basics of Variable References: Reference.).  Because variables
  3345. defined by `define' are recursively expanded variables, all the
  3346. variable references you wrote inside the `define' are expanded now.
  3347. For example:
  3348.  
  3349.      foo.c : foo.y
  3350.              $(run-yacc)
  3351.  
  3352. `foo.y' will be substituted for the variable `$^' when it occurs in
  3353. `run-yacc''s value, and `foo.c' for `$@'.
  3354.  
  3355.    This is a realistic example, but this particular one is not needed in
  3356. practice because `make' has an implicit rule to figure out these
  3357. commands based on the file names involved (*note Using Implicit Rules:
  3358. Implicit Rules.).
  3359.  
  3360.    In command execution, each line of a canned sequence is treated just
  3361. as if the line appeared on its own in the rule, preceded by a tab.  In
  3362. particular, `make' invokes a separate subshell for each line.  You can
  3363. use the special prefix characters that affect command lines (`@', `-',
  3364. and `+') on each line of a canned sequence.  *Note Writing the Commands
  3365. in Rules: Commands.  For example, using this canned sequence:
  3366.  
  3367.      define frobnicate
  3368.      @echo "frobnicating target $@"
  3369.      frob-step-1 $< -o $@-step-1
  3370.      frob-step-2 $@-step-1 -o $@
  3371.      endef
  3372.  
  3373. `make' will not echo the first line, the `echo' command.  But it _will_
  3374. echo the following two command lines.
  3375.  
  3376.    On the other hand, prefix characters on the command line that refers
  3377. to a canned sequence apply to every line in the sequence.  So the rule:
  3378.  
  3379.      frob.out: frob.in
  3380.              @$(frobnicate)
  3381.  
  3382. does not echo _any_ commands.  (*Note Command Echoing: Echoing, for a
  3383. full explanation of `@'.)
  3384.  
  3385. 
  3386. File: make,  Node: Empty Commands,  Prev: Sequences,  Up: Commands
  3387.  
  3388. 5.8 Using Empty Commands
  3389. ========================
  3390.  
  3391. It is sometimes useful to define commands which do nothing.  This is
  3392. done simply by giving a command that consists of nothing but
  3393. whitespace.  For example:
  3394.  
  3395.      target: ;
  3396.  
  3397. defines an empty command string for `target'.  You could also use a
  3398. line beginning with a tab character to define an empty command string,
  3399. but this would be confusing because such a line looks empty.
  3400.  
  3401.    You may be wondering why you would want to define a command string
  3402. that does nothing.  The only reason this is useful is to prevent a
  3403. target from getting implicit commands (from implicit rules or the
  3404. `.DEFAULT' special target; *note Implicit Rules:: and *note Defining
  3405. Last-Resort Default Rules: Last Resort.).
  3406.  
  3407.    You may be inclined to define empty command strings for targets that
  3408. are not actual files, but only exist so that their prerequisites can be
  3409. remade.  However, this is not the best way to do that, because the
  3410. prerequisites may not be remade properly if the target file actually
  3411. does exist.  *Note Phony Targets: Phony Targets, for a better way to do
  3412. this.
  3413.  
  3414. 
  3415. File: make,  Node: Using Variables,  Next: Conditionals,  Prev: Commands,  Up: Top
  3416.  
  3417. 6 How to Use Variables
  3418. **********************
  3419.  
  3420. A "variable" is a name defined in a makefile to represent a string of
  3421. text, called the variable's "value".  These values are substituted by
  3422. explicit request into targets, prerequisites, commands, and other parts
  3423. of the makefile.  (In some other versions of `make', variables are
  3424. called "macros".)  
  3425.  
  3426.    Variables and functions in all parts of a makefile are expanded when
  3427. read, except for the shell commands in rules, the right-hand sides of
  3428. variable definitions using `=', and the bodies of variable definitions
  3429. using the `define' directive.
  3430.  
  3431.    Variables can represent lists of file names, options to pass to
  3432. compilers, programs to run, directories to look in for source files,
  3433. directories to write output in, or anything else you can imagine.
  3434.  
  3435.    A variable name may be any sequence of characters not containing `:',
  3436. `#', `=', or leading or trailing whitespace.  However, variable names
  3437. containing characters other than letters, numbers, and underscores
  3438. should be avoided, as they may be given special meanings in the future,
  3439. and with some shells they cannot be passed through the environment to a
  3440. sub-`make' (*note Communicating Variables to a Sub-`make':
  3441. Variables/Recursion.).
  3442.  
  3443.    Variable names are case-sensitive.  The names `foo', `FOO', and
  3444. `Foo' all refer to different variables.
  3445.  
  3446.    It is traditional to use upper case letters in variable names, but we
  3447. recommend using lower case letters for variable names that serve
  3448. internal purposes in the makefile, and reserving upper case for
  3449. parameters that control implicit rules or for parameters that the user
  3450. should override with command options (*note Overriding Variables:
  3451. Overriding.).
  3452.  
  3453.    A few variables have names that are a single punctuation character or
  3454. just a few characters.  These are the "automatic variables", and they
  3455. have particular specialized uses.  *Note Automatic Variables: Automatic.
  3456.  
  3457. * Menu:
  3458.  
  3459. * Reference::                   How to use the value of a variable.
  3460. * Flavors::                     Variables come in two flavors.
  3461. * Advanced::                    Advanced features for referencing a variable.
  3462. * Values::                      All the ways variables get their values.
  3463. * Setting::                     How to set a variable in the makefile.
  3464. * Appending::                   How to append more text to the old value
  3465.                                   of a variable.
  3466. * Override Directive::          How to set a variable in the makefile even if
  3467.                                   the user has set it with a command argument.
  3468. * Defining::                    An alternate way to set a variable
  3469.                                   to a verbatim string.
  3470. * Environment::                 Variable values can come from the environment.
  3471. * Target-specific::             Variable values can be defined on a per-target
  3472.                                   basis.
  3473. * Pattern-specific::            Target-specific variable values can be applied
  3474.                                   to a group of targets that match a pattern.
  3475.  
  3476. 
  3477. File: make,  Node: Reference,  Next: Flavors,  Prev: Using Variables,  Up: Using Variables
  3478.  
  3479. 6.1 Basics of Variable References
  3480. =================================
  3481.  
  3482. To substitute a variable's value, write a dollar sign followed by the
  3483. name of the variable in parentheses or braces: either `$(foo)' or
  3484. `${foo}' is a valid reference to the variable `foo'.  This special
  3485. significance of `$' is why you must write `$$' to have the effect of a
  3486. single dollar sign in a file name or command.
  3487.  
  3488.    Variable references can be used in any context: targets,
  3489. prerequisites, commands, most directives, and new variable values.
  3490. Here is an example of a common case, where a variable holds the names
  3491. of all the object files in a program:
  3492.  
  3493.      objects = program.o foo.o utils.o
  3494.      program : $(objects)
  3495.              cc -o program $(objects)
  3496.  
  3497.      $(objects) : defs.h
  3498.  
  3499.    Variable references work by strict textual substitution.  Thus, the
  3500. rule
  3501.  
  3502.      foo = c
  3503.      prog.o : prog.$(foo)
  3504.              $(foo)$(foo) -$(foo) prog.$(foo)
  3505.  
  3506. could be used to compile a C program `prog.c'.  Since spaces before the
  3507. variable value are ignored in variable assignments, the value of `foo'
  3508. is precisely `c'.  (Don't actually write your makefiles this way!)
  3509.  
  3510.    A dollar sign followed by a character other than a dollar sign,
  3511. open-parenthesis or open-brace treats that single character as the
  3512. variable name.  Thus, you could reference the variable `x' with `$x'.
  3513. However, this practice is strongly discouraged, except in the case of
  3514. the automatic variables (*note Automatic Variables: Automatic.).
  3515.  
  3516. 
  3517. File: make,  Node: Flavors,  Next: Advanced,  Prev: Reference,  Up: Using Variables
  3518.  
  3519. 6.2 The Two Flavors of Variables
  3520. ================================
  3521.  
  3522. There are two ways that a variable in GNU `make' can have a value; we
  3523. call them the two "flavors" of variables.  The two flavors are
  3524. distinguished in how they are defined and in what they do when expanded.
  3525.  
  3526.    The first flavor of variable is a "recursively expanded" variable.
  3527. Variables of this sort are defined by lines using `=' (*note Setting
  3528. Variables: Setting.) or by the `define' directive (*note Defining
  3529. Variables Verbatim: Defining.).  The value you specify is installed
  3530. verbatim; if it contains references to other variables, these
  3531. references are expanded whenever this variable is substituted (in the
  3532. course of expanding some other string).  When this happens, it is
  3533. called "recursive expansion".
  3534.  
  3535.    For example,
  3536.  
  3537.      foo = $(bar)
  3538.      bar = $(ugh)
  3539.      ugh = Huh?
  3540.  
  3541.      all:;echo $(foo)
  3542.  
  3543. will echo `Huh?': `$(foo)' expands to `$(bar)' which expands to
  3544. `$(ugh)' which finally expands to `Huh?'.
  3545.  
  3546.    This flavor of variable is the only sort supported by other versions
  3547. of `make'.  It has its advantages and its disadvantages.  An advantage
  3548. (most would say) is that:
  3549.  
  3550.      CFLAGS = $(include_dirs) -O
  3551.      include_dirs = -Ifoo -Ibar
  3552.  
  3553. will do what was intended: when `CFLAGS' is expanded in a command, it
  3554. will expand to `-Ifoo -Ibar -O'.  A major disadvantage is that you
  3555. cannot append something on the end of a variable, as in
  3556.  
  3557.      CFLAGS = $(CFLAGS) -O
  3558.  
  3559. because it will cause an infinite loop in the variable expansion.
  3560. (Actually `make' detects the infinite loop and reports an error.)  
  3561.  
  3562.    Another disadvantage is that any functions (*note Functions for
  3563. Transforming Text: Functions.)  referenced in the definition will be
  3564. executed every time the variable is expanded.  This makes `make' run
  3565. slower; worse, it causes the `wildcard' and `shell' functions to give
  3566. unpredictable results because you cannot easily control when they are
  3567. called, or even how many times.
  3568.  
  3569.    To avoid all the problems and inconveniences of recursively expanded
  3570. variables, there is another flavor: simply expanded variables.
  3571.  
  3572.    "Simply expanded variables" are defined by lines using `:=' (*note
  3573. Setting Variables: Setting.).  The value of a simply expanded variable
  3574. is scanned once and for all, expanding any references to other
  3575. variables and functions, when the variable is defined.  The actual
  3576. value of the simply expanded variable is the result of expanding the
  3577. text that you write.  It does not contain any references to other
  3578. variables; it contains their values _as of the time this variable was
  3579. defined_.  Therefore,
  3580.  
  3581.      x := foo
  3582.      y := $(x) bar
  3583.      x := later
  3584.  
  3585. is equivalent to
  3586.  
  3587.      y := foo bar
  3588.      x := later
  3589.  
  3590.    When a simply expanded variable is referenced, its value is
  3591. substituted verbatim.
  3592.  
  3593.    Here is a somewhat more complicated example, illustrating the use of
  3594. `:=' in conjunction with the `shell' function.  (*Note The `shell'
  3595. Function: Shell Function.)  This example also shows use of the variable
  3596. `MAKELEVEL', which is changed when it is passed down from level to
  3597. level.  (*Note Communicating Variables to a Sub-`make':
  3598. Variables/Recursion, for information about `MAKELEVEL'.)
  3599.  
  3600.      ifeq (0,${MAKELEVEL})
  3601.      cur-dir   := $(shell pwd)
  3602.      whoami    := $(shell whoami)
  3603.      host-type := $(shell arch)
  3604.      MAKE := ${MAKE} host-type=${host-type} whoami=${whoami}
  3605.      endif
  3606.  
  3607. An advantage of this use of `:=' is that a typical `descend into a
  3608. directory' command then looks like this:
  3609.  
  3610.      ${subdirs}:
  3611.            ${MAKE} cur-dir=${cur-dir}/$@ -C $@ all
  3612.  
  3613.    Simply expanded variables generally make complicated makefile
  3614. programming more predictable because they work like variables in most
  3615. programming languages.  They allow you to redefine a variable using its
  3616. own value (or its value processed in some way by one of the expansion
  3617. functions) and to use the expansion functions much more efficiently
  3618. (*note Functions for Transforming Text: Functions.).
  3619.  
  3620.    You can also use them to introduce controlled leading whitespace into
  3621. variable values.  Leading whitespace characters are discarded from your
  3622. input before substitution of variable references and function calls;
  3623. this means you can include leading spaces in a variable value by
  3624. protecting them with variable references, like this:
  3625.  
  3626.      nullstring :=
  3627.      space := $(nullstring) # end of the line
  3628.  
  3629. Here the value of the variable `space' is precisely one space.  The
  3630. comment `# end of the line' is included here just for clarity.  Since
  3631. trailing space characters are _not_ stripped from variable values, just
  3632. a space at the end of the line would have the same effect (but be
  3633. rather hard to read).  If you put whitespace at the end of a variable
  3634. value, it is a good idea to put a comment like that at the end of the
  3635. line to make your intent clear.  Conversely, if you do _not_ want any
  3636. whitespace characters at the end of your variable value, you must
  3637. remember not to put a random comment on the end of the line after some
  3638. whitespace, such as this:
  3639.  
  3640.      dir := /foo/bar    # directory to put the frobs in
  3641.  
  3642. Here the value of the variable `dir' is `/foo/bar    ' (with four
  3643. trailing spaces), which was probably not the intention.  (Imagine
  3644. something like `$(dir)/file' with this definition!)
  3645.  
  3646.    There is another assignment operator for variables, `?='.  This is
  3647. called a conditional variable assignment operator, because it only has
  3648. an effect if the variable is not yet defined.  This statement:
  3649.  
  3650.      FOO ?= bar
  3651.  
  3652. is exactly equivalent to this (*note The `origin' Function: Origin
  3653. Function.):
  3654.  
  3655.      ifeq ($(origin FOO), undefined)
  3656.        FOO = bar
  3657.      endif
  3658.  
  3659.    Note that a variable set to an empty value is still defined, so `?='
  3660. will not set that variable.
  3661.  
  3662. 
  3663. File: make,  Node: Advanced,  Next: Values,  Prev: Flavors,  Up: Using Variables
  3664.  
  3665. 6.3 Advanced Features for Reference to Variables
  3666. ================================================
  3667.  
  3668. This section describes some advanced features you can use to reference
  3669. variables in more flexible ways.
  3670.  
  3671. * Menu:
  3672.  
  3673. * Substitution Refs::           Referencing a variable with
  3674.                                   substitutions on the value.
  3675. * Computed Names::              Computing the name of the variable to refer to.
  3676.  
  3677. 
  3678. File: make,  Node: Substitution Refs,  Next: Computed Names,  Prev: Advanced,  Up: Advanced
  3679.  
  3680. 6.3.1 Substitution References
  3681. -----------------------------
  3682.  
  3683. A "substitution reference" substitutes the value of a variable with
  3684. alterations that you specify.  It has the form `$(VAR:A=B)' (or
  3685. `${VAR:A=B}') and its meaning is to take the value of the variable VAR,
  3686. replace every A at the end of a word with B in that value, and
  3687. substitute the resulting string.
  3688.  
  3689.    When we say "at the end of a word", we mean that A must appear
  3690. either followed by whitespace or at the end of the value in order to be
  3691. replaced; other occurrences of A in the value are unaltered.  For
  3692. example:
  3693.  
  3694.      foo := a.o b.o c.o
  3695.      bar := $(foo:.o=.c)
  3696.  
  3697. sets `bar' to `a.c b.c c.c'.  *Note Setting Variables: Setting.
  3698.  
  3699.    A substitution reference is actually an abbreviation for use of the
  3700. `patsubst' expansion function (*note Functions for String Substitution
  3701. and Analysis: Text Functions.).  We provide substitution references as
  3702. well as `patsubst' for compatibility with other implementations of
  3703. `make'.
  3704.  
  3705.    Another type of substitution reference lets you use the full power of
  3706. the `patsubst' function.  It has the same form `$(VAR:A=B)' described
  3707. above, except that now A must contain a single `%' character.  This
  3708. case is equivalent to `$(patsubst A,B,$(VAR))'.  *Note Functions for
  3709. String Substitution and Analysis: Text Functions, for a description of
  3710. the `patsubst' function.
  3711.  
  3712. For example:
  3713.  
  3714.      foo := a.o b.o c.o
  3715.      bar := $(foo:%.o=%.c)
  3716.  
  3717. sets `bar' to `a.c b.c c.c'.
  3718.  
  3719. 
  3720. File: make,  Node: Computed Names,  Prev: Substitution Refs,  Up: Advanced
  3721.  
  3722. 6.3.2 Computed Variable Names
  3723. -----------------------------
  3724.  
  3725. Computed variable names are a complicated concept needed only for
  3726. sophisticated makefile programming.  For most purposes you need not
  3727. consider them, except to know that making a variable with a dollar sign
  3728. in its name might have strange results.  However, if you are the type
  3729. that wants to understand everything, or you are actually interested in
  3730. what they do, read on.
  3731.  
  3732.    Variables may be referenced inside the name of a variable.  This is
  3733. called a "computed variable name" or a "nested variable reference".
  3734. For example,
  3735.  
  3736.      x = y
  3737.      y = z
  3738.      a := $($(x))
  3739.  
  3740. defines `a' as `z': the `$(x)' inside `$($(x))' expands to `y', so
  3741. `$($(x))' expands to `$(y)' which in turn expands to `z'.  Here the
  3742. name of the variable to reference is not stated explicitly; it is
  3743. computed by expansion of `$(x)'.  The reference `$(x)' here is nested
  3744. within the outer variable reference.
  3745.  
  3746.    The previous example shows two levels of nesting, but any number of
  3747. levels is possible.  For example, here are three levels:
  3748.  
  3749.      x = y
  3750.      y = z
  3751.      z = u
  3752.      a := $($($(x)))
  3753.  
  3754. Here the innermost `$(x)' expands to `y', so `$($(x))' expands to
  3755. `$(y)' which in turn expands to `z'; now we have `$(z)', which becomes
  3756. `u'.
  3757.  
  3758.    References to recursively-expanded variables within a variable name
  3759. are reexpanded in the usual fashion.  For example:
  3760.  
  3761.      x = $(y)
  3762.      y = z
  3763.      z = Hello
  3764.      a := $($(x))
  3765.  
  3766. defines `a' as `Hello': `$($(x))' becomes `$($(y))' which becomes
  3767. `$(z)' which becomes `Hello'.
  3768.  
  3769.    Nested variable references can also contain modified references and
  3770. function invocations (*note Functions for Transforming Text:
  3771. Functions.), just like any other reference.  For example, using the
  3772. `subst' function (*note Functions for String Substitution and Analysis:
  3773. Text Functions.):
  3774.  
  3775.      x = variable1
  3776.      variable2 := Hello
  3777.      y = $(subst 1,2,$(x))
  3778.      z = y
  3779.      a := $($($(z)))
  3780.  
  3781. eventually defines `a' as `Hello'.  It is doubtful that anyone would
  3782. ever want to write a nested reference as convoluted as this one, but it
  3783. works: `$($($(z)))' expands to `$($(y))' which becomes `$($(subst
  3784. 1,2,$(x)))'.  This gets the value `variable1' from `x' and changes it
  3785. by substitution to `variable2', so that the entire string becomes
  3786. `$(variable2)', a simple variable reference whose value is `Hello'.
  3787.  
  3788.    A computed variable name need not consist entirely of a single
  3789. variable reference.  It can contain several variable references, as
  3790. well as some invariant text.  For example,
  3791.  
  3792.      a_dirs := dira dirb
  3793.      1_dirs := dir1 dir2
  3794.  
  3795.      a_files := filea fileb
  3796.      1_files := file1 file2
  3797.  
  3798.      ifeq "$(use_a)" "yes"
  3799.      a1 := a
  3800.      else
  3801.      a1 := 1
  3802.      endif
  3803.  
  3804.      ifeq "$(use_dirs)" "yes"
  3805.      df := dirs
  3806.      else
  3807.      df := files
  3808.      endif
  3809.  
  3810.      dirs := $($(a1)_$(df))
  3811.  
  3812. will give `dirs' the same value as `a_dirs', `1_dirs', `a_files' or
  3813. `1_files' depending on the settings of `use_a' and `use_dirs'.
  3814.  
  3815.    Computed variable names can also be used in substitution references:
  3816.  
  3817.      a_objects := a.o b.o c.o
  3818.      1_objects := 1.o 2.o 3.o
  3819.  
  3820.      sources := $($(a1)_objects:.o=.c)
  3821.  
  3822. defines `sources' as either `a.c b.c c.c' or `1.c 2.c 3.c', depending
  3823. on the value of `a1'.
  3824.  
  3825.    The only restriction on this sort of use of nested variable
  3826. references is that they cannot specify part of the name of a function
  3827. to be called.  This is because the test for a recognized function name
  3828. is done before the expansion of nested references.  For example,
  3829.  
  3830.      ifdef do_sort
  3831.      func := sort
  3832.      else
  3833.      func := strip
  3834.      endif
  3835.  
  3836.      bar := a d b g q c
  3837.  
  3838.      foo := $($(func) $(bar))
  3839.  
  3840. attempts to give `foo' the value of the variable `sort a d b g q c' or
  3841. `strip a d b g q c', rather than giving `a d b g q c' as the argument
  3842. to either the `sort' or the `strip' function.  This restriction could
  3843. be removed in the future if that change is shown to be a good idea.
  3844.  
  3845.    You can also use computed variable names in the left-hand side of a
  3846. variable assignment, or in a `define' directive, as in:
  3847.  
  3848.      dir = foo
  3849.      $(dir)_sources := $(wildcard $(dir)/*.c)
  3850.      define $(dir)_print
  3851.      lpr $($(dir)_sources)
  3852.      endef
  3853.  
  3854. This example defines the variables `dir', `foo_sources', and
  3855. `foo_print'.
  3856.  
  3857.    Note that "nested variable references" are quite different from
  3858. "recursively expanded variables" (*note The Two Flavors of Variables:
  3859. Flavors.), though both are used together in complex ways when doing
  3860. makefile programming.
  3861.  
  3862. 
  3863. File: make,  Node: Values,  Next: Setting,  Prev: Advanced,  Up: Using Variables
  3864.  
  3865. 6.4 How Variables Get Their Values
  3866. ==================================
  3867.  
  3868. Variables can get values in several different ways:
  3869.  
  3870.    * You can specify an overriding value when you run `make'.  *Note
  3871.      Overriding Variables: Overriding.
  3872.  
  3873.    * You can specify a value in the makefile, either with an assignment
  3874.      (*note Setting Variables: Setting.) or with a verbatim definition
  3875.      (*note Defining Variables Verbatim: Defining.).
  3876.  
  3877.    * Variables in the environment become `make' variables.  *Note
  3878.      Variables from the Environment: Environment.
  3879.  
  3880.    * Several "automatic" variables are given new values for each rule.
  3881.      Each of these has a single conventional use.  *Note Automatic
  3882.      Variables: Automatic.
  3883.  
  3884.    * Several variables have constant initial values.  *Note Variables
  3885.      Used by Implicit Rules: Implicit Variables.
  3886.  
  3887. 
  3888. File: make,  Node: Setting,  Next: Appending,  Prev: Values,  Up: Using Variables
  3889.  
  3890. 6.5 Setting Variables
  3891. =====================
  3892.  
  3893. To set a variable from the makefile, write a line starting with the
  3894. variable name followed by `=' or `:='.  Whatever follows the `=' or
  3895. `:=' on the line becomes the value.  For example,
  3896.  
  3897.      objects = main.o foo.o bar.o utils.o
  3898.  
  3899. defines a variable named `objects'.  Whitespace around the variable
  3900. name and immediately after the `=' is ignored.
  3901.  
  3902.    Variables defined with `=' are "recursively expanded" variables.
  3903. Variables defined with `:=' are "simply expanded" variables; these
  3904. definitions can contain variable references which will be expanded
  3905. before the definition is made.  *Note The Two Flavors of Variables:
  3906. Flavors.
  3907.  
  3908.    The variable name may contain function and variable references, which
  3909. are expanded when the line is read to find the actual variable name to
  3910. use.
  3911.  
  3912.    There is no limit on the length of the value of a variable except the
  3913. amount of swapping space on the computer.  When a variable definition is
  3914. long, it is a good idea to break it into several lines by inserting
  3915. backslash-newline at convenient places in the definition.  This will not
  3916. affect the functioning of `make', but it will make the makefile easier
  3917. to read.
  3918.  
  3919.    Most variable names are considered to have the empty string as a
  3920. value if you have never set them.  Several variables have built-in
  3921. initial values that are not empty, but you can set them in the usual
  3922. ways (*note Variables Used by Implicit Rules: Implicit Variables.).
  3923. Several special variables are set automatically to a new value for each
  3924. rule; these are called the "automatic" variables (*note Automatic
  3925. Variables: Automatic.).
  3926.  
  3927.    If you'd like a variable to be set to a value only if it's not
  3928. already set, then you can use the shorthand operator `?=' instead of
  3929. `='.  These two settings of the variable `FOO' are identical (*note The
  3930. `origin' Function: Origin Function.):
  3931.  
  3932.      FOO ?= bar
  3933.  
  3934. and
  3935.  
  3936.      ifeq ($(origin FOO), undefined)
  3937.      FOO = bar
  3938.      endif
  3939.  
  3940. 
  3941. File: make,  Node: Appending,  Next: Override Directive,  Prev: Setting,  Up: Using Variables
  3942.  
  3943. 6.6 Appending More Text to Variables
  3944. ====================================
  3945.  
  3946. Often it is useful to add more text to the value of a variable already
  3947. defined.  You do this with a line containing `+=', like this:
  3948.  
  3949.      objects += another.o
  3950.  
  3951. This takes the value of the variable `objects', and adds the text
  3952. `another.o' to it (preceded by a single space).  Thus:
  3953.  
  3954.      objects = main.o foo.o bar.o utils.o
  3955.      objects += another.o
  3956.  
  3957. sets `objects' to `main.o foo.o bar.o utils.o another.o'.
  3958.  
  3959.    Using `+=' is similar to:
  3960.  
  3961.      objects = main.o foo.o bar.o utils.o
  3962.      objects := $(objects) another.o
  3963.  
  3964. but differs in ways that become important when you use more complex
  3965. values.
  3966.  
  3967.    When the variable in question has not been defined before, `+=' acts
  3968. just like normal `=': it defines a recursively-expanded variable.
  3969. However, when there _is_ a previous definition, exactly what `+=' does
  3970. depends on what flavor of variable you defined originally.  *Note The
  3971. Two Flavors of Variables: Flavors, for an explanation of the two
  3972. flavors of variables.
  3973.  
  3974.    When you add to a variable's value with `+=', `make' acts
  3975. essentially as if you had included the extra text in the initial
  3976. definition of the variable.  If you defined it first with `:=', making
  3977. it a simply-expanded variable, `+=' adds to that simply-expanded
  3978. definition, and expands the new text before appending it to the old
  3979. value just as `:=' does (*note Setting Variables: Setting, for a full
  3980. explanation of `:=').  In fact,
  3981.  
  3982.      variable := value
  3983.      variable += more
  3984.  
  3985. is exactly equivalent to:
  3986.  
  3987.  
  3988.      variable := value
  3989.      variable := $(variable) more
  3990.  
  3991.    On the other hand, when you use `+=' with a variable that you defined
  3992. first to be recursively-expanded using plain `=', `make' does something
  3993. a bit different.  Recall that when you define a recursively-expanded
  3994. variable, `make' does not expand the value you set for variable and
  3995. function references immediately.  Instead it stores the text verbatim,
  3996. and saves these variable and function references to be expanded later,
  3997. when you refer to the new variable (*note The Two Flavors of Variables:
  3998. Flavors.).  When you use `+=' on a recursively-expanded variable, it is
  3999. this unexpanded text to which `make' appends the new text you specify.
  4000.  
  4001.      variable = value
  4002.      variable += more
  4003.  
  4004. is roughly equivalent to:
  4005.  
  4006.      temp = value
  4007.      variable = $(temp) more
  4008.  
  4009. except that of course it never defines a variable called `temp'.  The
  4010. importance of this comes when the variable's old value contains
  4011. variable references.  Take this common example:
  4012.  
  4013.      CFLAGS = $(includes) -O
  4014.      ...
  4015.      CFLAGS += -pg # enable profiling
  4016.  
  4017. The first line defines the `CFLAGS' variable with a reference to another
  4018. variable, `includes'.  (`CFLAGS' is used by the rules for C
  4019. compilation; *note Catalogue of Implicit Rules: Catalogue of Rules.)
  4020. Using `=' for the definition makes `CFLAGS' a recursively-expanded
  4021. variable, meaning `$(includes) -O' is _not_ expanded when `make'
  4022. processes the definition of `CFLAGS'.  Thus, `includes' need not be
  4023. defined yet for its value to take effect.  It only has to be defined
  4024. before any reference to `CFLAGS'.  If we tried to append to the value
  4025. of `CFLAGS' without using `+=', we might do it like this:
  4026.  
  4027.      CFLAGS := $(CFLAGS) -pg # enable profiling
  4028.  
  4029. This is pretty close, but not quite what we want.  Using `:=' redefines
  4030. `CFLAGS' as a simply-expanded variable; this means `make' expands the
  4031. text `$(CFLAGS) -pg' before setting the variable.  If `includes' is not
  4032. yet defined, we get ` -O -pg', and a later definition of `includes'
  4033. will have no effect.  Conversely, by using `+=' we set `CFLAGS' to the
  4034. _unexpanded_ value `$(includes) -O -pg'.  Thus we preserve the
  4035. reference to `includes', so if that variable gets defined at any later
  4036. point, a reference like `$(CFLAGS)' still uses its value.
  4037.  
  4038. 
  4039. File: make,  Node: Override Directive,  Next: Defining,  Prev: Appending,  Up: Using Variables
  4040.  
  4041. 6.7 The `override' Directive
  4042. ============================
  4043.  
  4044. If a variable has been set with a command argument (*note Overriding
  4045. Variables: Overriding.), then ordinary assignments in the makefile are
  4046. ignored.  If you want to set the variable in the makefile even though
  4047. it was set with a command argument, you can use an `override'
  4048. directive, which is a line that looks like this:
  4049.  
  4050.      override VARIABLE = VALUE
  4051.  
  4052. or
  4053.  
  4054.      override VARIABLE := VALUE
  4055.  
  4056.    To append more text to a variable defined on the command line, use:
  4057.  
  4058.      override VARIABLE += MORE TEXT
  4059.  
  4060. *Note Appending More Text to Variables: Appending.
  4061.  
  4062.    The `override' directive was not invented for escalation in the war
  4063. between makefiles and command arguments.  It was invented so you can
  4064. alter and add to values that the user specifies with command arguments.
  4065.  
  4066.    For example, suppose you always want the `-g' switch when you run the
  4067. C compiler, but you would like to allow the user to specify the other
  4068. switches with a command argument just as usual.  You could use this
  4069. `override' directive:
  4070.  
  4071.      override CFLAGS += -g
  4072.  
  4073.    You can also use `override' directives with `define' directives.
  4074. This is done as you might expect:
  4075.  
  4076.      override define foo
  4077.      bar
  4078.      endef
  4079.  
  4080. *Note Defining Variables Verbatim: Defining.
  4081.  
  4082. 
  4083. File: make,  Node: Defining,  Next: Environment,  Prev: Override Directive,  Up: Using Variables
  4084.  
  4085. 6.8 Defining Variables Verbatim
  4086. ===============================
  4087.  
  4088. Another way to set the value of a variable is to use the `define'
  4089. directive.  This directive has an unusual syntax which allows newline
  4090. characters to be included in the value, which is convenient for defining
  4091. both canned sequences of commands (*note Defining Canned Command
  4092. Sequences: Sequences.), and also sections of makefile syntax to use
  4093. with `eval' (*note Eval Function::).
  4094.  
  4095.    The `define' directive is followed on the same line by the name of
  4096. the variable and nothing more.  The value to give the variable appears
  4097. on the following lines.  The end of the value is marked by a line
  4098. containing just the word `endef'.  Aside from this difference in
  4099. syntax, `define' works just like `=': it creates a recursively-expanded
  4100. variable (*note The Two Flavors of Variables: Flavors.).  The variable
  4101. name may contain function and variable references, which are expanded
  4102. when the directive is read to find the actual variable name to use.
  4103.  
  4104.    You may nest `define' directives: `make' will keep track of nested
  4105. directives and report an error if they are not all properly closed with
  4106. `endef'.  Note that lines beginning with tab characters are considered
  4107. part of a command script, so any `define' or `endef' strings appearing
  4108. on such a line will not be considered `make' operators.
  4109.  
  4110.      define two-lines
  4111.      echo foo
  4112.      echo $(bar)
  4113.      endef
  4114.  
  4115.    The value in an ordinary assignment cannot contain a newline; but the
  4116. newlines that separate the lines of the value in a `define' become part
  4117. of the variable's value (except for the final newline which precedes
  4118. the `endef' and is not considered part of the value).
  4119.  
  4120.    When used in a command script, the previous example is functionally
  4121. equivalent to this:
  4122.  
  4123.      two-lines = echo foo; echo $(bar)
  4124.  
  4125. since two commands separated by semicolon behave much like two separate
  4126. shell commands.  However, note that using two separate lines means
  4127. `make' will invoke the shell twice, running an independent subshell for
  4128. each line.  *Note Command Execution: Execution.
  4129.  
  4130.    If you want variable definitions made with `define' to take
  4131. precedence over command-line variable definitions, you can use the
  4132. `override' directive together with `define':
  4133.  
  4134.      override define two-lines
  4135.      foo
  4136.      $(bar)
  4137.      endef
  4138.  
  4139. *Note The `override' Directive: Override Directive.
  4140.  
  4141. 
  4142. File: make,  Node: Environment,  Next: Target-specific,  Prev: Defining,  Up: Using Variables
  4143.  
  4144. 6.9 Variables from the Environment
  4145. ==================================
  4146.  
  4147. Variables in `make' can come from the environment in which `make' is
  4148. run.  Every environment variable that `make' sees when it starts up is
  4149. transformed into a `make' variable with the same name and value.  But
  4150. an explicit assignment in the makefile, or with a command argument,
  4151. overrides the environment.  (If the `-e' flag is specified, then values
  4152. from the environment override assignments in the makefile.  *Note
  4153. Summary of Options: Options Summary.  But this is not recommended
  4154. practice.)
  4155.  
  4156.    Thus, by setting the variable `CFLAGS' in your environment, you can
  4157. cause all C compilations in most makefiles to use the compiler switches
  4158. you prefer.  This is safe for variables with standard or conventional
  4159. meanings because you know that no makefile will use them for other
  4160. things.  (But this is not totally reliable; some makefiles set `CFLAGS'
  4161. explicitly and therefore are not affected by the value in the
  4162. environment.)
  4163.  
  4164.    When `make' is invoked recursively, variables defined in the outer
  4165. invocation can be passed to inner invocations through the environment
  4166. (*note Recursive Use of `make': Recursion.).  By default, only
  4167. variables that came from the environment or the command line are passed
  4168. to recursive invocations.  You can use the `export' directive to pass
  4169. other variables.  *Note Communicating Variables to a Sub-`make':
  4170. Variables/Recursion, for full details.
  4171.  
  4172.    Other use of variables from the environment is not recommended.  It
  4173. is not wise for makefiles to depend for their functioning on
  4174. environment variables set up outside their control, since this would
  4175. cause different users to get different results from the same makefile.
  4176. This is against the whole purpose of most makefiles.
  4177.  
  4178.    Such problems would be especially likely with the variable `SHELL',
  4179. which is normally present in the environment to specify the user's
  4180. choice of interactive shell.  It would be very undesirable for this
  4181. choice to affect `make'.  So `make' ignores the environment value of
  4182. `SHELL' (except on MS-DOS and MS-Windows, where `SHELL' is usually not
  4183. set.  *Note Special handling of SHELL on MS-DOS: Execution.)
  4184.  
  4185. 
  4186. File: make,  Node: Target-specific,  Next: Pattern-specific,  Prev: Environment,  Up: Using Variables
  4187.  
  4188. 6.10 Target-specific Variable Values
  4189. ====================================
  4190.  
  4191. Variable values in `make' are usually global; that is, they are the
  4192. same regardless of where they are evaluated (unless they're reset, of
  4193. course).  One exception to that is automatic variables (*note Automatic
  4194. Variables: Automatic.).
  4195.  
  4196.    The other exception is "target-specific variable values".  This
  4197. feature allows you to define different values for the same variable,
  4198. based on the target that `make' is currently building.  As with
  4199. automatic variables, these values are only available within the context
  4200. of a target's command script (and in other target-specific assignments).
  4201.  
  4202.    Set a target-specific variable value like this:
  4203.  
  4204.      TARGET ... : VARIABLE-ASSIGNMENT
  4205.  
  4206. or like this:
  4207.  
  4208.      TARGET ... : override VARIABLE-ASSIGNMENT
  4209.  
  4210.    Multiple TARGET values create a target-specific variable value for
  4211. each member of the target list individually.
  4212.  
  4213.    The VARIABLE-ASSIGNMENT can be any valid form of assignment;
  4214. recursive (`='), static (`:='), appending (`+='), or conditional
  4215. (`?=').  All variables that appear within the VARIABLE-ASSIGNMENT are
  4216. evaluated within the context of the target: thus, any
  4217. previously-defined target-specific variable values will be in effect.
  4218. Note that this variable is actually distinct from any "global" value:
  4219. the two variables do not have to have the same flavor (recursive vs.
  4220. static).
  4221.  
  4222.    Target-specific variables have the same priority as any other
  4223. makefile variable.  Variables provided on the command-line (and in the
  4224. environment if the `-e' option is in force) will take precedence.
  4225. Specifying the `override' directive will allow the target-specific
  4226. variable value to be preferred.
  4227.  
  4228.    There is one more special feature of target-specific variables: when
  4229. you define a target-specific variable, that variable value is also in
  4230. effect for all prerequisites of this target (unless those prerequisites
  4231. override it with their own target-specific variable value).  So, for
  4232. example, a statement like this:
  4233.  
  4234.      prog : CFLAGS = -g
  4235.      prog : prog.o foo.o bar.o
  4236.  
  4237. will set `CFLAGS' to `-g' in the command script for `prog', but it will
  4238. also set `CFLAGS' to `-g' in the command scripts that create `prog.o',
  4239. `foo.o', and `bar.o', and any command scripts which create their
  4240. prerequisites.
  4241.  
  4242. 
  4243. File: make,  Node: Pattern-specific,  Prev: Target-specific,  Up: Using Variables
  4244.  
  4245. 6.11 Pattern-specific Variable Values
  4246. =====================================
  4247.  
  4248. In addition to target-specific variable values (*note Target-specific
  4249. Variable Values: Target-specific.), GNU `make' supports
  4250. pattern-specific variable values.  In this form, a variable is defined
  4251. for any target that matches the pattern specified.  Variables defined in
  4252. this way are searched after any target-specific variables defined
  4253. explicitly for that target, and before target-specific variables defined
  4254. for the parent target.
  4255.  
  4256.    Set a pattern-specific variable value like this:
  4257.  
  4258.      PATTERN ... : VARIABLE-ASSIGNMENT
  4259.  
  4260. or like this:
  4261.  
  4262.      PATTERN ... : override VARIABLE-ASSIGNMENT
  4263.  
  4264. where PATTERN is a %-pattern.  As with target-specific variable values,
  4265. multiple PATTERN values create a pattern-specific variable value for
  4266. each pattern individually.  The VARIABLE-ASSIGNMENT can be any valid
  4267. form of assignment.  Any command-line variable setting will take
  4268. precedence, unless `override' is specified.
  4269.  
  4270.    For example:
  4271.  
  4272.      %.o : CFLAGS = -O
  4273.  
  4274. will assign `CFLAGS' the value of `-O' for all targets matching the
  4275. pattern `%.o'.
  4276.  
  4277. 
  4278. File: make,  Node: Conditionals,  Next: Functions,  Prev: Using Variables,  Up: Top
  4279.  
  4280. 7 Conditional Parts of Makefiles
  4281. ********************************
  4282.  
  4283. A "conditional" causes part of a makefile to be obeyed or ignored
  4284. depending on the values of variables.  Conditionals can compare the
  4285. value of one variable to another, or the value of a variable to a
  4286. constant string.  Conditionals control what `make' actually "sees" in
  4287. the makefile, so they _cannot_ be used to control shell commands at the
  4288. time of execution.
  4289.  
  4290. * Menu:
  4291.  
  4292. * Conditional Example::         Example of a conditional
  4293. * Conditional Syntax::          The syntax of conditionals.
  4294. * Testing Flags::               Conditionals that test flags.
  4295.  
  4296. 
  4297. File: make,  Node: Conditional Example,  Next: Conditional Syntax,  Prev: Conditionals,  Up: Conditionals
  4298.  
  4299. 7.1 Example of a Conditional
  4300. ============================
  4301.  
  4302. The following example of a conditional tells `make' to use one set of
  4303. libraries if the `CC' variable is `gcc', and a different set of
  4304. libraries otherwise.  It works by controlling which of two command
  4305. lines will be used as the command for a rule.  The result is that
  4306. `CC=gcc' as an argument to `make' changes not only which compiler is
  4307. used but also which libraries are linked.
  4308.  
  4309.      libs_for_gcc = -lgnu
  4310.      normal_libs =
  4311.  
  4312.      foo: $(objects)
  4313.      ifeq ($(CC),gcc)
  4314.              $(CC) -o foo $(objects) $(libs_for_gcc)
  4315.      else
  4316.              $(CC) -o foo $(objects) $(normal_libs)
  4317.      endif
  4318.  
  4319.    This conditional uses three directives: one `ifeq', one `else' and
  4320. one `endif'.
  4321.  
  4322.    The `ifeq' directive begins the conditional, and specifies the
  4323. condition.  It contains two arguments, separated by a comma and
  4324. surrounded by parentheses.  Variable substitution is performed on both
  4325. arguments and then they are compared.  The lines of the makefile
  4326. following the `ifeq' are obeyed if the two arguments match; otherwise
  4327. they are ignored.
  4328.  
  4329.    The `else' directive causes the following lines to be obeyed if the
  4330. previous conditional failed.  In the example above, this means that the
  4331. second alternative linking command is used whenever the first
  4332. alternative is not used.  It is optional to have an `else' in a
  4333. conditional.
  4334.  
  4335.    The `endif' directive ends the conditional.  Every conditional must
  4336. end with an `endif'.  Unconditional makefile text follows.
  4337.  
  4338.    As this example illustrates, conditionals work at the textual level:
  4339. the lines of the conditional are treated as part of the makefile, or
  4340. ignored, according to the condition.  This is why the larger syntactic
  4341. units of the makefile, such as rules, may cross the beginning or the
  4342. end of the conditional.
  4343.  
  4344.    When the variable `CC' has the value `gcc', the above example has
  4345. this effect:
  4346.  
  4347.      foo: $(objects)
  4348.              $(CC) -o foo $(objects) $(libs_for_gcc)
  4349.  
  4350. When the variable `CC' has any other value, the effect is this:
  4351.  
  4352.      foo: $(objects)
  4353.              $(CC) -o foo $(objects) $(normal_libs)
  4354.  
  4355.    Equivalent results can be obtained in another way by
  4356. conditionalizing a variable assignment and then using the variable
  4357. unconditionally:
  4358.  
  4359.      libs_for_gcc = -lgnu
  4360.      normal_libs =
  4361.  
  4362.      ifeq ($(CC),gcc)
  4363.        libs=$(libs_for_gcc)
  4364.      else
  4365.        libs=$(normal_libs)
  4366.      endif
  4367.  
  4368.      foo: $(objects)
  4369.              $(CC) -o foo $(objects) $(libs)
  4370.  
  4371. 
  4372. File: make,  Node: Conditional Syntax,  Next: Testing Flags,  Prev: Conditional Example,  Up: Conditionals
  4373.  
  4374. 7.2 Syntax of Conditionals
  4375. ==========================
  4376.  
  4377. The syntax of a simple conditional with no `else' is as follows:
  4378.  
  4379.      CONDITIONAL-DIRECTIVE
  4380.      TEXT-IF-TRUE
  4381.      endif
  4382.  
  4383. The TEXT-IF-TRUE may be any lines of text, to be considered as part of
  4384. the makefile if the condition is true.  If the condition is false, no
  4385. text is used instead.
  4386.  
  4387.    The syntax of a complex conditional is as follows:
  4388.  
  4389.      CONDITIONAL-DIRECTIVE
  4390.      TEXT-IF-TRUE
  4391.      else
  4392.      TEXT-IF-FALSE
  4393.      endif
  4394.  
  4395. If the condition is true, TEXT-IF-TRUE is used; otherwise,
  4396. TEXT-IF-FALSE is used instead.  The TEXT-IF-FALSE can be any number of
  4397. lines of text.
  4398.  
  4399.    The syntax of the CONDITIONAL-DIRECTIVE is the same whether the
  4400. conditional is simple or complex.  There are four different directives
  4401. that test different conditions.  Here is a table of them:
  4402.  
  4403. `ifeq (ARG1, ARG2)'
  4404. `ifeq 'ARG1' 'ARG2''
  4405. `ifeq "ARG1" "ARG2"'
  4406. `ifeq "ARG1" 'ARG2''
  4407. `ifeq 'ARG1' "ARG2"'
  4408.      Expand all variable references in ARG1 and ARG2 and compare them.
  4409.      If they are identical, the TEXT-IF-TRUE is effective; otherwise,
  4410.      the TEXT-IF-FALSE, if any, is effective.
  4411.  
  4412.      Often you want to test if a variable has a non-empty value.  When
  4413.      the value results from complex expansions of variables and
  4414.      functions, expansions you would consider empty may actually
  4415.      contain whitespace characters and thus are not seen as empty.
  4416.      However, you can use the `strip' function (*note Text Functions::)
  4417.      to avoid interpreting whitespace as a non-empty value.  For
  4418.      example:
  4419.  
  4420.           ifeq ($(strip $(foo)),)
  4421.           TEXT-IF-EMPTY
  4422.           endif
  4423.  
  4424.      will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)'
  4425.      contains whitespace characters.
  4426.  
  4427. `ifneq (ARG1, ARG2)'
  4428. `ifneq 'ARG1' 'ARG2''
  4429. `ifneq "ARG1" "ARG2"'
  4430. `ifneq "ARG1" 'ARG2''
  4431. `ifneq 'ARG1' "ARG2"'
  4432.      Expand all variable references in ARG1 and ARG2 and compare them.
  4433.      If they are different, the TEXT-IF-TRUE is effective; otherwise,
  4434.      the TEXT-IF-FALSE, if any, is effective.
  4435.  
  4436. `ifdef VARIABLE-NAME'
  4437.      If the variable VARIABLE-NAME has a non-empty value, the
  4438.      TEXT-IF-TRUE is effective; otherwise, the TEXT-IF-FALSE, if any,
  4439.      is effective.  Variables that have never been defined have an
  4440.      empty value.  The variable VARIABLE-NAME is itself expanded, so it
  4441.      could be a variable or function that expands to the name of a
  4442.      variable.
  4443.  
  4444.      Note that `ifdef' only tests whether a variable has a value.  It
  4445.      does not expand the variable to see if that value is nonempty.
  4446.      Consequently, tests using `ifdef' return true for all definitions
  4447.      except those like `foo ='.  To test for an empty value, use
  4448.      `ifeq ($(foo),)'.  For example,
  4449.  
  4450.           bar =
  4451.           foo = $(bar)
  4452.           ifdef foo
  4453.           frobozz = yes
  4454.           else
  4455.           frobozz = no
  4456.           endif
  4457.  
  4458.      sets `frobozz' to `yes', while:
  4459.  
  4460.           foo =
  4461.           ifdef foo
  4462.           frobozz = yes
  4463.           else
  4464.           frobozz = no
  4465.           endif
  4466.  
  4467.      sets `frobozz' to `no'.
  4468.  
  4469. `ifndef VARIABLE-NAME'
  4470.      If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE
  4471.      is effective; otherwise, the TEXT-IF-FALSE, if any, is effective.
  4472.  
  4473.    Extra spaces are allowed and ignored at the beginning of the
  4474. conditional directive line, but a tab is not allowed.  (If the line
  4475. begins with a tab, it will be considered a command for a rule.)  Aside
  4476. from this, extra spaces or tabs may be inserted with no effect anywhere
  4477. except within the directive name or within an argument.  A comment
  4478. starting with `#' may appear at the end of the line.
  4479.  
  4480.    The other two directives that play a part in a conditional are `else'
  4481. and `endif'.  Each of these directives is written as one word, with no
  4482. arguments.  Extra spaces are allowed and ignored at the beginning of the
  4483. line, and spaces or tabs at the end.  A comment starting with `#' may
  4484. appear at the end of the line.
  4485.  
  4486.    Conditionals affect which lines of the makefile `make' uses.  If the
  4487. condition is true, `make' reads the lines of the TEXT-IF-TRUE as part
  4488. of the makefile; if the condition is false, `make' ignores those lines
  4489. completely.  It follows that syntactic units of the makefile, such as
  4490. rules, may safely be split across the beginning or the end of the
  4491. conditional.
  4492.  
  4493.    `make' evaluates conditionals when it reads a makefile.
  4494. Consequently, you cannot use automatic variables in the tests of
  4495. conditionals because they are not defined until commands are run (*note
  4496. Automatic Variables: Automatic.).
  4497.  
  4498.    To prevent intolerable confusion, it is not permitted to start a
  4499. conditional in one makefile and end it in another.  However, you may
  4500. write an `include' directive within a conditional, provided you do not
  4501. attempt to terminate the conditional inside the included file.
  4502.  
  4503. 
  4504. File: make,  Node: Testing Flags,  Prev: Conditional Syntax,  Up: Conditionals
  4505.  
  4506. 7.3 Conditionals that Test Flags
  4507. ================================
  4508.  
  4509. You can write a conditional that tests `make' command flags such as
  4510. `-t' by using the variable `MAKEFLAGS' together with the `findstring'
  4511. function (*note Functions for String Substitution and Analysis: Text
  4512. Functions.).  This is useful when `touch' is not enough to make a file
  4513. appear up to date.
  4514.  
  4515.    The `findstring' function determines whether one string appears as a
  4516. substring of another.  If you want to test for the `-t' flag, use `t'
  4517. as the first string and the value of `MAKEFLAGS' as the other.
  4518.  
  4519.    For example, here is how to arrange to use `ranlib -t' to finish
  4520. marking an archive file up to date:
  4521.  
  4522.      archive.a: ...
  4523.      ifneq (,$(findstring t,$(MAKEFLAGS)))
  4524.              +touch archive.a
  4525.              +ranlib -t archive.a
  4526.      else
  4527.              ranlib archive.a
  4528.      endif
  4529.  
  4530. The `+' prefix marks those command lines as "recursive" so that they
  4531. will be executed despite use of the `-t' flag.  *Note Recursive Use of
  4532. `make': Recursion.
  4533.  
  4534. 
  4535. File: make,  Node: Functions,  Next: Running,  Prev: Conditionals,  Up: Top
  4536.  
  4537. 8 Functions for Transforming Text
  4538. *********************************
  4539.  
  4540. "Functions" allow you to do text processing in the makefile to compute
  4541. the files to operate on or the commands to use.  You use a function in a
  4542. "function call", where you give the name of the function and some text
  4543. (the "arguments") for the function to operate on.  The result of the
  4544. function's processing is substituted into the makefile at the point of
  4545. the call, just as a variable might be substituted.
  4546.  
  4547. * Menu:
  4548.  
  4549. * Syntax of Functions::         How to write a function call.
  4550. * Text Functions::              General-purpose text manipulation functions.
  4551. * File Name Functions::         Functions for manipulating file names.
  4552. * Foreach Function::            Repeat some text with controlled variation.
  4553. * If Function::                 Conditionally expand a value.
  4554. * Call Function::               Expand a user-defined function.
  4555. * Value Function::              Return the un-expanded value of a variable.
  4556. * Eval Function::               Evaluate the arguments as makefile syntax.
  4557. * Origin Function::             Find where a variable got its value.
  4558. * Shell Function::              Substitute the output of a shell command.
  4559. * Make Control Functions::      Functions that control how make runs.
  4560.  
  4561. 
  4562. File: make,  Node: Syntax of Functions,  Next: Text Functions,  Prev: Functions,  Up: Functions
  4563.  
  4564. 8.1 Function Call Syntax
  4565. ========================
  4566.  
  4567. A function call resembles a variable reference.  It looks like this:
  4568.  
  4569.      $(FUNCTION ARGUMENTS)
  4570.  
  4571. or like this:
  4572.  
  4573.      ${FUNCTION ARGUMENTS}
  4574.  
  4575.    Here FUNCTION is a function name; one of a short list of names that
  4576. are part of `make'.  You can also essentially create your own functions
  4577. by using the `call' builtin function.
  4578.  
  4579.    The ARGUMENTS are the arguments of the function.  They are separated
  4580. from the function name by one or more spaces or tabs, and if there is
  4581. more than one argument, then they are separated by commas.  Such
  4582. whitespace and commas are not part of an argument's value.  The
  4583. delimiters which you use to surround the function call, whether
  4584. parentheses or braces, can appear in an argument only in matching pairs;
  4585. the other kind of delimiters may appear singly.  If the arguments
  4586. themselves contain other function calls or variable references, it is
  4587. wisest to use the same kind of delimiters for all the references; write
  4588. `$(subst a,b,$(x))', not `$(subst a,b,${x})'.  This is because it is
  4589. clearer, and because only one type of delimiter is matched to find the
  4590. end of the reference.
  4591.  
  4592.    The text written for each argument is processed by substitution of
  4593. variables and function calls to produce the argument value, which is
  4594. the text on which the function acts.  The substitution is done in the
  4595. order in which the arguments appear.
  4596.  
  4597.    Commas and unmatched parentheses or braces cannot appear in the text
  4598. of an argument as written; leading spaces cannot appear in the text of
  4599. the first argument as written.  These characters can be put into the
  4600. argument value by variable substitution.  First define variables
  4601. `comma' and `space' whose values are isolated comma and space
  4602. characters, then substitute these variables where such characters are
  4603. wanted, like this:
  4604.  
  4605.      comma:= ,
  4606.      empty:=
  4607.      space:= $(empty) $(empty)
  4608.      foo:= a b c
  4609.      bar:= $(subst $(space),$(comma),$(foo))
  4610.      # bar is now `a,b,c'.
  4611.  
  4612. Here the `subst' function replaces each space with a comma, through the
  4613. value of `foo', and substitutes the result.
  4614.  
  4615. 
  4616. File: make,  Node: Text Functions,  Next: File Name Functions,  Prev: Syntax of Functions,  Up: Functions
  4617.  
  4618. 8.2 Functions for String Substitution and Analysis
  4619. ==================================================
  4620.  
  4621. Here are some functions that operate on strings:
  4622.  
  4623. `$(subst FROM,TO,TEXT)'
  4624.      Performs a textual replacement on the text TEXT: each occurrence
  4625.      of FROM is replaced by TO.  The result is substituted for the
  4626.      function call.  For example,
  4627.  
  4628.           $(subst ee,EE,feet on the street)
  4629.  
  4630.      substitutes the string `fEEt on the strEEt'.
  4631.  
  4632. `$(patsubst PATTERN,REPLACEMENT,TEXT)'
  4633.      Finds whitespace-separated words in TEXT that match PATTERN and
  4634.      replaces them with REPLACEMENT.  Here PATTERN may contain a `%'
  4635.      which acts as a wildcard, matching any number of any characters
  4636.      within a word.  If REPLACEMENT also contains a `%', the `%' is
  4637.      replaced by the text that matched the `%' in PATTERN.  Only the
  4638.      first `%' in the PATTERN and REPLACEMENT is treated this way; any
  4639.      subsequent `%' is unchanged.
  4640.  
  4641.      `%' characters in `patsubst' function invocations can be quoted
  4642.      with preceding backslashes (`\').  Backslashes that would
  4643.      otherwise quote `%' characters can be quoted with more backslashes.
  4644.      Backslashes that quote `%' characters or other backslashes are
  4645.      removed from the pattern before it is compared file names or has a
  4646.      stem substituted into it.  Backslashes that are not in danger of
  4647.      quoting `%' characters go unmolested.  For example, the pattern
  4648.      `the\%weird\\%pattern\\' has `the%weird\' preceding the operative
  4649.      `%' character, and `pattern\\' following it.  The final two
  4650.      backslashes are left alone because they cannot affect any `%'
  4651.      character.
  4652.  
  4653.      Whitespace between words is folded into single space characters;
  4654.      leading and trailing whitespace is discarded.
  4655.  
  4656.      For example,
  4657.  
  4658.           $(patsubst %.c,%.o,x.c.c bar.c)
  4659.  
  4660.      produces the value `x.c.o bar.o'.
  4661.  
  4662.      Substitution references (*note Substitution References:
  4663.      Substitution Refs.) are a simpler way to get the effect of the
  4664.      `patsubst' function:
  4665.  
  4666.           $(VAR:PATTERN=REPLACEMENT)
  4667.  
  4668.      is equivalent to
  4669.  
  4670.           $(patsubst PATTERN,REPLACEMENT,$(VAR))
  4671.  
  4672.      The second shorthand simplifies one of the most common uses of
  4673.      `patsubst': replacing the suffix at the end of file names.
  4674.  
  4675.           $(VAR:SUFFIX=REPLACEMENT)
  4676.  
  4677.      is equivalent to
  4678.  
  4679.           $(patsubst %SUFFIX,%REPLACEMENT,$(VAR))
  4680.  
  4681.      For example, you might have a list of object files:
  4682.  
  4683.           objects = foo.o bar.o baz.o
  4684.  
  4685.      To get the list of corresponding source files, you could simply
  4686.      write:
  4687.  
  4688.           $(objects:.o=.c)
  4689.  
  4690.      instead of using the general form:
  4691.  
  4692.           $(patsubst %.o,%.c,$(objects))
  4693.  
  4694. `$(strip STRING)'
  4695.      Removes leading and trailing whitespace from STRING and replaces
  4696.      each internal sequence of one or more whitespace characters with a
  4697.      single space.  Thus, `$(strip a b  c )' results in `a b c'.
  4698.  
  4699.      The function `strip' can be very useful when used in conjunction
  4700.      with conditionals.  When comparing something with the empty string
  4701.      `' using `ifeq' or `ifneq', you usually want a string of just
  4702.      whitespace to match the empty string (*note Conditionals::).
  4703.  
  4704.      Thus, the following may fail to have the desired results:
  4705.  
  4706.           .PHONY: all
  4707.           ifneq   "$(needs_made)" ""
  4708.           all: $(needs_made)
  4709.           else
  4710.           all:;@echo 'Nothing to make!'
  4711.           endif
  4712.  
  4713.      Replacing the variable reference `$(needs_made)' with the function
  4714.      call `$(strip $(needs_made))' in the `ifneq' directive would make
  4715.      it more robust.
  4716.  
  4717. `$(findstring FIND,IN)'
  4718.      Searches IN for an occurrence of FIND.  If it occurs, the value is
  4719.      FIND; otherwise, the value is empty.  You can use this function in
  4720.      a conditional to test for the presence of a specific substring in
  4721.      a given string.  Thus, the two examples,
  4722.  
  4723.           $(findstring a,a b c)
  4724.           $(findstring a,b c)
  4725.  
  4726.      produce the values `a' and `' (the empty string), respectively.
  4727.      *Note Testing Flags::, for a practical application of `findstring'.
  4728.  
  4729. `$(filter PATTERN...,TEXT)'
  4730.      Returns all whitespace-separated words in TEXT that _do_ match any
  4731.      of the PATTERN words, removing any words that _do not_ match.  The
  4732.      patterns are written using `%', just like the patterns used in the
  4733.      `patsubst' function above.
  4734.  
  4735.      The `filter' function can be used to separate out different types
  4736.      of strings (such as file names) in a variable.  For example:
  4737.  
  4738.           sources := foo.c bar.c baz.s ugh.h
  4739.           foo: $(sources)
  4740.                   cc $(filter %.c %.s,$(sources)) -o foo
  4741.  
  4742.      says that `foo' depends of `foo.c', `bar.c', `baz.s' and `ugh.h'
  4743.      but only `foo.c', `bar.c' and `baz.s' should be specified in the
  4744.      command to the compiler.
  4745.  
  4746. `$(filter-out PATTERN...,TEXT)'
  4747.      Returns all whitespace-separated words in TEXT that _do not_ match
  4748.      any of the PATTERN words, removing the words that _do_ match one
  4749.      or more.  This is the exact opposite of the `filter' function.
  4750.  
  4751.      For example, given:
  4752.  
  4753.           objects=main1.o foo.o main2.o bar.o
  4754.           mains=main1.o main2.o
  4755.  
  4756.      the following generates a list which contains all the object files
  4757.      not in `mains':
  4758.  
  4759.           $(filter-out $(mains),$(objects))
  4760.  
  4761. `$(sort LIST)'
  4762.      Sorts the words of LIST in lexical order, removing duplicate
  4763.      words.  The output is a list of words separated by single spaces.
  4764.      Thus,
  4765.  
  4766.           $(sort foo bar lose)
  4767.  
  4768.      returns the value `bar foo lose'.
  4769.  
  4770.      Incidentally, since `sort' removes duplicate words, you can use it
  4771.      for this purpose even if you don't care about the sort order.
  4772.  
  4773. `$(word N,TEXT)'
  4774.      Returns the Nth word of TEXT.  The legitimate values of N start
  4775.      from 1.  If N is bigger than the number of words in TEXT, the
  4776.      value is empty.  For example,
  4777.  
  4778.           $(word 2, foo bar baz)
  4779.  
  4780.      returns `bar'.
  4781.  
  4782. `$(wordlist S,E,TEXT)'
  4783.      Returns the list of words in TEXT starting with word S and ending
  4784.      with word E (inclusive).  The legitimate values of S and E start
  4785.      from 1.  If S is bigger than the number of words in TEXT, the
  4786.      value is empty.  If E is bigger than the number of words in TEXT,
  4787.      words up to the end of TEXT are returned.  If S is greater than E,
  4788.      nothing is returned.  For example,
  4789.  
  4790.           $(wordlist 2, 3, foo bar baz)
  4791.  
  4792.      returns `bar baz'.
  4793.  
  4794. `$(words TEXT)'
  4795.      Returns the number of words in TEXT.  Thus, the last word of TEXT
  4796.      is `$(word $(words TEXT),TEXT)'.
  4797.  
  4798. `$(firstword NAMES...)'
  4799.      The argument NAMES is regarded as a series of names, separated by
  4800.      whitespace.  The value is the first name in the series.  The rest
  4801.      of the names are ignored.
  4802.  
  4803.      For example,
  4804.  
  4805.           $(firstword foo bar)
  4806.  
  4807.      produces the result `foo'.  Although `$(firstword TEXT)' is the
  4808.      same as `$(word 1,TEXT)', the `firstword' function is retained for
  4809.      its simplicity.
  4810.  
  4811.    Here is a realistic example of the use of `subst' and `patsubst'.
  4812. Suppose that a makefile uses the `VPATH' variable to specify a list of
  4813. directories that `make' should search for prerequisite files (*note
  4814. `VPATH' Search Path for All Prerequisites: General Search.).  This
  4815. example shows how to tell the C compiler to search for header files in
  4816. the same list of directories.
  4817.  
  4818.    The value of `VPATH' is a list of directories separated by colons,
  4819. such as `src:../headers'.  First, the `subst' function is used to
  4820. change the colons to spaces:
  4821.  
  4822.      $(subst :, ,$(VPATH))
  4823.  
  4824. This produces `src ../headers'.  Then `patsubst' is used to turn each
  4825. directory name into a `-I' flag.  These can be added to the value of
  4826. the variable `CFLAGS', which is passed automatically to the C compiler,
  4827. like this:
  4828.  
  4829.      override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH)))
  4830.  
  4831. The effect is to append the text `-Isrc -I../headers' to the previously
  4832. given value of `CFLAGS'.  The `override' directive is used so that the
  4833. new value is assigned even if the previous value of `CFLAGS' was
  4834. specified with a command argument (*note The `override' Directive:
  4835. Override Directive.).
  4836.  
  4837. 
  4838. File: make,  Node: File Name Functions,  Next: Foreach Function,  Prev: Text Functions,  Up: Functions
  4839.  
  4840. 8.3 Functions for File Names
  4841. ============================
  4842.  
  4843. Several of the built-in expansion functions relate specifically to
  4844. taking apart file names or lists of file names.
  4845.  
  4846.    Each of the following functions performs a specific transformation
  4847. on a file name.  The argument of the function is regarded as a series
  4848. of file names, separated by whitespace.  (Leading and trailing
  4849. whitespace is ignored.)  Each file name in the series is transformed in
  4850. the same way and the results are concatenated with single spaces
  4851. between them.
  4852.  
  4853. `$(dir NAMES...)'
  4854.      Extracts the directory-part of each file name in NAMES.  The
  4855.      directory-part of the file name is everything up through (and
  4856.      including) the last slash in it.  If the file name contains no
  4857.      slash, the directory part is the string `./'.  For example,
  4858.  
  4859.           $(dir src/foo.c hacks)
  4860.  
  4861.      produces the result `src/ ./'.
  4862.  
  4863. `$(notdir NAMES...)'
  4864.      Extracts all but the directory-part of each file name in NAMES.
  4865.      If the file name contains no slash, it is left unchanged.
  4866.      Otherwise, everything through the last slash is removed from it.
  4867.  
  4868.      A file name that ends with a slash becomes an empty string.  This
  4869.      is unfortunate, because it means that the result does not always
  4870.      have the same number of whitespace-separated file names as the
  4871.      argument had; but we do not see any other valid alternative.
  4872.  
  4873.      For example,
  4874.  
  4875.           $(notdir src/foo.c hacks)
  4876.  
  4877.      produces the result `foo.c hacks'.
  4878.  
  4879. `$(suffix NAMES...)'
  4880.      Extracts the suffix of each file name in NAMES.  If the file name
  4881.      contains a period, the suffix is everything starting with the last
  4882.      period.  Otherwise, the suffix is the empty string.  This
  4883.      frequently means that the result will be empty when NAMES is not,
  4884.      and if NAMES contains multiple file names, the result may contain
  4885.      fewer file names.
  4886.  
  4887.      For example,
  4888.  
  4889.           $(suffix src/foo.c src-1.0/bar.c hacks)
  4890.  
  4891.      produces the result `.c .c'.
  4892.  
  4893. `$(basename NAMES...)'
  4894.      Extracts all but the suffix of each file name in NAMES.  If the
  4895.      file name contains a period, the basename is everything starting
  4896.      up to (and not including) the last period.  Periods in the
  4897.      directory part are ignored.  If there is no period, the basename
  4898.      is the entire file name.  For example,
  4899.  
  4900.           $(basename src/foo.c src-1.0/bar hacks)
  4901.  
  4902.      produces the result `src/foo src-1.0/bar hacks'.
  4903.  
  4904. `$(addsuffix SUFFIX,NAMES...)'
  4905.      The argument NAMES is regarded as a series of names, separated by
  4906.      whitespace; SUFFIX is used as a unit.  The value of SUFFIX is
  4907.      appended to the end of each individual name and the resulting
  4908.      larger names are concatenated with single spaces between them.
  4909.      For example,
  4910.  
  4911.           $(addsuffix .c,foo bar)
  4912.  
  4913.      produces the result `foo.c bar.c'.
  4914.  
  4915. `$(addprefix PREFIX,NAMES...)'
  4916.      The argument NAMES is regarded as a series of names, separated by
  4917.      whitespace; PREFIX is used as a unit.  The value of PREFIX is
  4918.      prepended to the front of each individual name and the resulting
  4919.      larger names are concatenated with single spaces between them.
  4920.      For example,
  4921.  
  4922.           $(addprefix src/,foo bar)
  4923.  
  4924.      produces the result `src/foo src/bar'.
  4925.  
  4926. `$(join LIST1,LIST2)'
  4927.      Concatenates the two arguments word by word: the two first words
  4928.      (one from each argument) concatenated form the first word of the
  4929.      result, the two second words form the second word of the result,
  4930.      and so on.  So the Nth word of the result comes from the Nth word
  4931.      of each argument.  If one argument has more words that the other,
  4932.      the extra words are copied unchanged into the result.
  4933.  
  4934.      For example, `$(join a b,.c .o)' produces `a.c b.o'.
  4935.  
  4936.      Whitespace between the words in the lists is not preserved; it is
  4937.      replaced with a single space.
  4938.  
  4939.      This function can merge the results of the `dir' and `notdir'
  4940.      functions, to produce the original list of files which was given
  4941.      to those two functions.
  4942.  
  4943. `$(wildcard PATTERN)'
  4944.      The argument PATTERN is a file name pattern, typically containing
  4945.      wildcard characters (as in shell file name patterns).  The result
  4946.      of `wildcard' is a space-separated list of the names of existing
  4947.      files that match the pattern.  *Note Using Wildcard Characters in
  4948.      File Names: Wildcards.
  4949.  
  4950. 
  4951. File: make,  Node: Foreach Function,  Next: If Function,  Prev: File Name Functions,  Up: Functions
  4952.  
  4953. 8.4 The `foreach' Function
  4954. ==========================
  4955.  
  4956. The `foreach' function is very different from other functions.  It
  4957. causes one piece of text to be used repeatedly, each time with a
  4958. different substitution performed on it.  It resembles the `for' command
  4959. in the shell `sh' and the `foreach' command in the C-shell `csh'.
  4960.  
  4961.    The syntax of the `foreach' function is:
  4962.  
  4963.      $(foreach VAR,LIST,TEXT)
  4964.  
  4965. The first two arguments, VAR and LIST, are expanded before anything
  4966. else is done; note that the last argument, TEXT, is *not* expanded at
  4967. the same time.  Then for each word of the expanded value of LIST, the
  4968. variable named by the expanded value of VAR is set to that word, and
  4969. TEXT is expanded.  Presumably TEXT contains references to that
  4970. variable, so its expansion will be different each time.
  4971.  
  4972.    The result is that TEXT is expanded as many times as there are
  4973. whitespace-separated words in LIST.  The multiple expansions of TEXT
  4974. are concatenated, with spaces between them, to make the result of
  4975. `foreach'.
  4976.  
  4977.    This simple example sets the variable `files' to the list of all
  4978. files in the directories in the list `dirs':
  4979.  
  4980.      dirs := a b c d
  4981.      files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
  4982.  
  4983.    Here TEXT is `$(wildcard $(dir)/*)'.  The first repetition finds the
  4984. value `a' for `dir', so it produces the same result as `$(wildcard
  4985. a/*)'; the second repetition produces the result of `$(wildcard b/*)';
  4986. and the third, that of `$(wildcard c/*)'.
  4987.  
  4988.    This example has the same result (except for setting `dirs') as the
  4989. following example:
  4990.  
  4991.      files := $(wildcard a/* b/* c/* d/*)
  4992.  
  4993.    When TEXT is complicated, you can improve readability by giving it a
  4994. name, with an additional variable:
  4995.  
  4996.      find_files = $(wildcard $(dir)/*)
  4997.      dirs := a b c d
  4998.      files := $(foreach dir,$(dirs),$(find_files))
  4999.  
  5000. Here we use the variable `find_files' this way.  We use plain `=' to
  5001. define a recursively-expanding variable, so that its value contains an
  5002. actual function call to be reexpanded under the control of `foreach'; a
  5003. simply-expanded variable would not do, since `wildcard' would be called
  5004. only once at the time of defining `find_files'.
  5005.  
  5006.    The `foreach' function has no permanent effect on the variable VAR;
  5007. its value and flavor after the `foreach' function call are the same as
  5008. they were beforehand.  The other values which are taken from LIST are
  5009. in effect only temporarily, during the execution of `foreach'.  The
  5010. variable VAR is a simply-expanded variable during the execution of
  5011. `foreach'.  If VAR was undefined before the `foreach' function call, it
  5012. is undefined after the call.  *Note The Two Flavors of Variables:
  5013. Flavors.
  5014.  
  5015.    You must take care when using complex variable expressions that
  5016. result in variable names because many strange things are valid variable
  5017. names, but are probably not what you intended.  For example,
  5018.  
  5019.      files := $(foreach Esta escrito en espanol!,b c ch,$(find_files))
  5020.  
  5021. might be useful if the value of `find_files' references the variable
  5022. whose name is `Esta escrito en espanol!' (es un nombre bastante largo,
  5023. no?), but it is more likely to be a mistake.
  5024.  
  5025. 
  5026. File: make,  Node: If Function,  Next: Call Function,  Prev: Foreach Function,  Up: Functions
  5027.  
  5028. 8.5 The `if' Function
  5029. =====================
  5030.  
  5031. The `if' function provides support for conditional expansion in a
  5032. functional context (as opposed to the GNU `make' makefile conditionals
  5033. such as `ifeq' (*note Syntax of Conditionals: Conditional Syntax.).
  5034.  
  5035.    An `if' function call can contain either two or three arguments:
  5036.  
  5037.      $(if CONDITION,THEN-PART[,ELSE-PART])
  5038.  
  5039.    The first argument, CONDITION, first has all preceding and trailing
  5040. whitespace stripped, then is expanded.  If it expands to any non-empty
  5041. string, then the condition is considered to be true.  If it expands to
  5042. an empty string, the condition is considered to be false.
  5043.  
  5044.    If the condition is true then the second argument, THEN-PART, is
  5045. evaluated and this is used as the result of the evaluation of the entire
  5046. `if' function.
  5047.  
  5048.    If the condition is false then the third argument, ELSE-PART, is
  5049. evaluated and this is the result of the `if' function.  If there is no
  5050. third argument, the `if' function evaluates to nothing (the empty
  5051. string).
  5052.  
  5053.    Note that only one of the THEN-PART or the ELSE-PART will be
  5054. evaluated, never both.  Thus, either can contain side-effects (such as
  5055. `shell' function calls, etc.)
  5056.  
  5057. 
  5058. File: make,  Node: Call Function,  Next: Value Function,  Prev: If Function,  Up: Functions
  5059.  
  5060. 8.6 The `call' Function
  5061. =======================
  5062.  
  5063. The `call' function is unique in that it can be used to create new
  5064. parameterized functions.  You can write a complex expression as the
  5065. value of a variable, then use `call' to expand it with different values.
  5066.  
  5067.    The syntax of the `call' function is:
  5068.  
  5069.      $(call VARIABLE,PARAM,PARAM,...)
  5070.  
  5071.    When `make' expands this function, it assigns each PARAM to
  5072. temporary variables `$(1)', `$(2)', etc.  The variable `$(0)' will
  5073. contain VARIABLE.  There is no maximum number of parameter arguments.
  5074. There is no minimum, either, but it doesn't make sense to use `call'
  5075. with no parameters.
  5076.  
  5077.    Then VARIABLE is expanded as a `make' variable in the context of
  5078. these temporary assignments.  Thus, any reference to `$(1)' in the
  5079. value of VARIABLE will resolve to the first PARAM in the invocation of
  5080. `call'.
  5081.  
  5082.    Note that VARIABLE is the _name_ of a variable, not a _reference_ to
  5083. that variable.  Therefore you would not normally use a `$' or
  5084. parentheses when writing it.  (You can, however, use a variable
  5085. reference in the name if you want the name not to be a constant.)
  5086.  
  5087.    If VARIABLE is the name of a builtin function, the builtin function
  5088. is always invoked (even if a `make' variable by that name also exists).
  5089.  
  5090.    The `call' function expands the PARAM arguments before assigning
  5091. them to temporary variables.  This means that VARIABLE values
  5092. containing references to builtin functions that have special expansion
  5093. rules, like `foreach' or `if', may not work as you expect.
  5094.  
  5095.    Some examples may make this clearer.
  5096.  
  5097.    This macro simply reverses its arguments:
  5098.  
  5099.      reverse = $(2) $(1)
  5100.  
  5101.      foo = $(call reverse,a,b)
  5102.  
  5103. Here FOO will contain `b a'.
  5104.  
  5105.    This one is slightly more interesting: it defines a macro to search
  5106. for the first instance of a program in `PATH':
  5107.  
  5108.      pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
  5109.  
  5110.      LS := $(call pathsearch,ls)
  5111.  
  5112. Now the variable LS contains `/bin/ls' or similar.
  5113.  
  5114.    The `call' function can be nested.  Each recursive invocation gets
  5115. its own local values for `$(1)', etc. that mask the values of
  5116. higher-level `call'.  For example, here is an implementation of a "map"
  5117. function:
  5118.  
  5119.      map = $(foreach a,$(2),$(call $(1),$(a)))
  5120.  
  5121.    Now you can MAP a function that normally takes only one argument,
  5122. such as `origin', to multiple values in one step:
  5123.  
  5124.      o = $(call map,origin,o map MAKE)
  5125.  
  5126.    and end up with O containing something like `file file default'.
  5127.  
  5128.    A final caution: be careful when adding whitespace to the arguments
  5129. to `call'.  As with other functions, any whitespace contained in the
  5130. second and subsequent arguments is kept; this can cause strange
  5131. effects.  It's generally safest to remove all extraneous whitespace when
  5132. providing parameters to `call'.
  5133.  
  5134. 
  5135. File: make,  Node: Value Function,  Next: Eval Function,  Prev: Call Function,  Up: Functions
  5136.  
  5137. 8.7 The `value' Function
  5138. ========================
  5139.  
  5140. The `value' function provides a way for you to use the value of a
  5141. variable _without_ having it expanded.  Please note that this does not
  5142. undo expansions which have already occurred; for example if you create
  5143. a simply expanded variable its value is expanded during the definition;
  5144. in that case the `value' function will return the same result as using
  5145. the variable directly.
  5146.  
  5147.    The syntax of the `value' function is:
  5148.  
  5149.      $(value VARIABLE)
  5150.  
  5151.    Note that VARIABLE is the _name_ of a variable; not a _reference_ to
  5152. that variable.  Therefore you would not normally use a `$' or
  5153. parentheses when writing it.  (You can, however, use a variable
  5154. reference in the name if you want the name not to be a constant.)
  5155.  
  5156.    The result of this function is a string containing the value of
  5157. VARIABLE, without any expansion occurring.  For example, in this
  5158. makefile:
  5159.  
  5160.      FOO = $PATH
  5161.  
  5162.      all:
  5163.              @echo $(FOO)
  5164.              @echo $(value FOO)
  5165.  
  5166. The first output line would be `ATH', since the "$P" would be expanded
  5167. as a `make' variable, while the second output line would be the current
  5168. value of your `$PATH' environment variable, since the `value' function
  5169. avoided the expansion.
  5170.  
  5171.    The `value' function is most often used in conjunction with the
  5172. `eval' function (*note Eval Function::).
  5173.  
  5174. 
  5175. File: make,  Node: Eval Function,  Next: Origin Function,  Prev: Value Function,  Up: Functions
  5176.  
  5177. 8.8 The `eval' Function
  5178. =======================
  5179.  
  5180. The `eval' function is very special: it allows you to define new
  5181. makefile constructs that are not constant; which are the result of
  5182. evaluating other variables and functions.  The argument to the `eval'
  5183. function is expanded, then the results of that expansion are parsed as
  5184. makefile syntax.  The expanded results can define new `make' variables,
  5185. targets, implicit or explicit rules, etc.
  5186.  
  5187.    The result of the `eval' function is always the empty string; thus,
  5188. it can be placed virtually anywhere in a makefile without causing
  5189. syntax errors.
  5190.  
  5191.    It's important to realize that the `eval' argument is expanded
  5192. _twice_; first by the `eval' function, then the results of that
  5193. expansion are expanded again when they are parsed as makefile syntax.
  5194. This means you may need to provide extra levels of escaping for "$"
  5195. characters when using `eval'.  The `value' function (*note Value
  5196. Function::) can sometimes be useful in these situations, to circumvent
  5197. unwanted expansions.
  5198.  
  5199.    Here is an example of how `eval' can be used; this example combines
  5200. a number of concepts and other functions.  Although it might seem
  5201. overly complex to use `eval' in this example, rather than just writing
  5202. out the rules, consider two things: first, the template definition (in
  5203. `PROGRAM_template') could need to be much more complex than it is here;
  5204. and second, you might put the complex, "generic" part of this example
  5205. into another makefile, then include it in all the individual makefiles.
  5206. Now your individual makefiles are quite straightforward.
  5207.  
  5208.      PROGRAMS    = server client
  5209.  
  5210.      server_OBJS = server.o server_priv.o server_access.o
  5211.      server_LIBS = priv protocol
  5212.  
  5213.      client_OBJS = client.o client_api.o client_mem.o
  5214.      client_LIBS = protocol
  5215.  
  5216.      # Everything after this is generic
  5217.  
  5218.      .PHONY: all
  5219.      all: $(PROGRAMS)
  5220.  
  5221.      define PROGRAM_template
  5222.       $(1): $$($(1)_OBJ) $$($(1)_LIBS:%=-l%)
  5223.       ALL_OBJS   += $$($(1)_OBJS)
  5224.      endef
  5225.  
  5226.      $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))
  5227.  
  5228.      $(PROGRAMS):
  5229.              $(LINK.o) $^ $(LDLIBS) -o $@
  5230.  
  5231.      clean:
  5232.              rm -f $(ALL_OBJS) $(PROGRAMS)
  5233.  
  5234. 
  5235. File: make,  Node: Origin Function,  Next: Shell Function,  Prev: Eval Function,  Up: Functions
  5236.  
  5237. 8.9 The `origin' Function
  5238. =========================
  5239.  
  5240. The `origin' function is unlike most other functions in that it does
  5241. not operate on the values of variables; it tells you something _about_
  5242. a variable.  Specifically, it tells you where it came from.
  5243.  
  5244.    The syntax of the `origin' function is:
  5245.  
  5246.      $(origin VARIABLE)
  5247.  
  5248.    Note that VARIABLE is the _name_ of a variable to inquire about; not
  5249. a _reference_ to that variable.  Therefore you would not normally use a
  5250. `$' or parentheses when writing it.  (You can, however, use a variable
  5251. reference in the name if you want the name not to be a constant.)
  5252.  
  5253.    The result of this function is a string telling you how the variable
  5254. VARIABLE was defined:
  5255.  
  5256. `undefined'
  5257.      if VARIABLE was never defined.
  5258.  
  5259. `default'
  5260.      if VARIABLE has a default definition, as is usual with `CC' and so
  5261.      on.  *Note Variables Used by Implicit Rules: Implicit Variables.
  5262.      Note that if you have redefined a default variable, the `origin'
  5263.      function will return the origin of the later definition.
  5264.  
  5265. `environment'
  5266.      if VARIABLE was defined as an environment variable and the `-e'
  5267.      option is _not_ turned on (*note Summary of Options: Options
  5268.      Summary.).
  5269.  
  5270. `environment override'
  5271.      if VARIABLE was defined as an environment variable and the `-e'
  5272.      option _is_ turned on (*note Summary of Options: Options Summary.).
  5273.  
  5274. `file'
  5275.      if VARIABLE was defined in a makefile.
  5276.  
  5277. `command line'
  5278.      if VARIABLE was defined on the command line.
  5279.  
  5280. `override'
  5281.      if VARIABLE was defined with an `override' directive in a makefile
  5282.      (*note The `override' Directive: Override Directive.).
  5283.  
  5284. `automatic'
  5285.      if VARIABLE is an automatic variable defined for the execution of
  5286.      the commands for each rule (*note Automatic Variables: Automatic.).
  5287.  
  5288.    This information is primarily useful (other than for your curiosity)
  5289. to determine if you want to believe the value of a variable.  For
  5290. example, suppose you have a makefile `foo' that includes another
  5291. makefile `bar'.  You want a variable `bletch' to be defined in `bar' if
  5292. you run the command `make -f bar', even if the environment contains a
  5293. definition of `bletch'.  However, if `foo' defined `bletch' before
  5294. including `bar', you do not want to override that definition.  This
  5295. could be done by using an `override' directive in `foo', giving that
  5296. definition precedence over the later definition in `bar';
  5297. unfortunately, the `override' directive would also override any command
  5298. line definitions.  So, `bar' could include:
  5299.  
  5300.      ifdef bletch
  5301.      ifeq "$(origin bletch)" "environment"
  5302.      bletch = barf, gag, etc.
  5303.      endif
  5304.      endif
  5305.  
  5306. If `bletch' has been defined from the environment, this will redefine
  5307. it.
  5308.  
  5309.    If you want to override a previous definition of `bletch' if it came
  5310. from the environment, even under `-e', you could instead write:
  5311.  
  5312.      ifneq "$(findstring environment,$(origin bletch))" ""
  5313.      bletch = barf, gag, etc.
  5314.      endif
  5315.  
  5316.    Here the redefinition takes place if `$(origin bletch)' returns
  5317. either `environment' or `environment override'.  *Note Functions for
  5318. String Substitution and Analysis: Text Functions.
  5319.  
  5320. 
  5321. File: make,  Node: Shell Function,  Next: Make Control Functions,  Prev: Origin Function,  Up: Functions
  5322.  
  5323. 8.10 The `shell' Function
  5324. =========================
  5325.  
  5326. The `shell' function is unlike any other function except the `wildcard'
  5327. function (*note The Function `wildcard': Wildcard Function.) in that it
  5328. communicates with the world outside of `make'.
  5329.  
  5330.    The `shell' function performs the same function that backquotes
  5331. (``') perform in most shells: it does "command expansion".  This means
  5332. that it takes an argument that is a shell command and returns the
  5333. output of the command.  The only processing `make' does on the result,
  5334. before substituting it into the surrounding text, is to convert each
  5335. newline or carriage-return / newline pair to a single space.  It also
  5336. removes the trailing (carriage-return and) newline, if it's the last
  5337. thing in the result.
  5338.  
  5339.    The commands run by calls to the `shell' function are run when the
  5340. function calls are expanded (*note How `make' Reads a Makefile: Reading
  5341. Makefiles.).  Because this function involves spawning a new shell, you
  5342. should carefully consider the performance implications of using the
  5343. `shell' function within recursively expanded variables vs. simply
  5344. expanded variables (*note The Two Flavors of Variables: Flavors.).
  5345.  
  5346.    Here are some examples of the use of the `shell' function:
  5347.  
  5348.      contents := $(shell cat foo)
  5349.  
  5350. sets `contents' to the contents of the file `foo', with a space (rather
  5351. than a newline) separating each line.
  5352.  
  5353.      files := $(shell echo *.c)
  5354.  
  5355. sets `files' to the expansion of `*.c'.  Unless `make' is using a very
  5356. strange shell, this has the same result as `$(wildcard *.c)'.
  5357.  
  5358. 
  5359. File: make,  Node: Make Control Functions,  Prev: Shell Function,  Up: Functions
  5360.  
  5361. 8.11 Functions That Control Make
  5362. ================================
  5363.  
  5364. These functions control the way make runs.  Generally, they are used to
  5365. provide information to the user of the makefile or to cause make to stop
  5366. if some sort of environmental error is detected.
  5367.  
  5368. `$(error TEXT...)'
  5369.      Generates a fatal error where the message is TEXT.  Note that the
  5370.      error is generated whenever this function is evaluated.  So, if
  5371.      you put it inside a command script or on the right side of a
  5372.      recursive variable assignment, it won't be evaluated until later.
  5373.      The TEXT will be expanded before the error is generated.
  5374.  
  5375.      For example,
  5376.  
  5377.           ifdef ERROR1
  5378.           $(error error is $(ERROR1))
  5379.           endif
  5380.  
  5381.      will generate a fatal error during the read of the makefile if the
  5382.      `make' variable `ERROR1' is defined.  Or,
  5383.  
  5384.           ERR = $(error found an error!)
  5385.  
  5386.           .PHONY: err
  5387.           err: ; $(ERR)
  5388.  
  5389.      will generate a fatal error while `make' is running, if the `err'
  5390.      target is invoked.
  5391.  
  5392. `$(warning TEXT...)'
  5393.      This function works similarly to the `error' function, above,
  5394.      except that `make' doesn't exit.  Instead, TEXT is expanded and
  5395.      the resulting message is displayed, but processing of the makefile
  5396.      continues.
  5397.  
  5398.      The result of the expansion of this function is the empty string.
  5399.  
  5400. 
  5401. File: make,  Node: Running,  Next: Implicit Rules,  Prev: Functions,  Up: Top
  5402.  
  5403. 9 How to Run `make'
  5404. *******************
  5405.  
  5406. A makefile that says how to recompile a program can be used in more
  5407. than one way.  The simplest use is to recompile every file that is out
  5408. of date.  Usually, makefiles are written so that if you run `make' with
  5409. no arguments, it does just that.
  5410.  
  5411.    But you might want to update only some of the files; you might want
  5412. to use a different compiler or different compiler options; you might
  5413. want just to find out which files are out of date without changing them.
  5414.  
  5415.    By giving arguments when you run `make', you can do any of these
  5416. things and many others.
  5417.  
  5418.    The exit status of `make' is always one of three values:
  5419. `0'
  5420.      The exit status is zero if `make' is successful.
  5421.  
  5422. `2'
  5423.      The exit status is two if `make' encounters any errors.  It will
  5424.      print messages describing the particular errors.
  5425.  
  5426. `1'
  5427.      The exit status is one if you use the `-q' flag and `make'
  5428.      determines that some target is not already up to date.  *Note
  5429.      Instead of Executing the Commands: Instead of Execution.
  5430.  
  5431. * Menu:
  5432.  
  5433. * Makefile Arguments::          How to specify which makefile to use.
  5434. * Goals::                       How to use goal arguments to specify which
  5435.                                   parts of the makefile to use.
  5436. * Instead of Execution::        How to use mode flags to specify what
  5437.                                   kind of thing to do with the commands
  5438.                                   in the makefile other than simply
  5439.                                   execute them.
  5440. * Avoiding Compilation::        How to avoid recompiling certain files.
  5441. * Overriding::                  How to override a variable to specify
  5442.                                   an alternate compiler and other things.
  5443. * Testing::                     How to proceed past some errors, to
  5444.                                   test compilation.
  5445. * Options Summary::             Summary of Options
  5446.  
  5447. 
  5448. File: make,  Node: Makefile Arguments,  Next: Goals,  Prev: Running,  Up: Running
  5449.  
  5450. 9.1 Arguments to Specify the Makefile
  5451. =====================================
  5452.  
  5453. The way to specify the name of the makefile is with the `-f' or
  5454. `--file' option (`--makefile' also works).  For example, `-f altmake'
  5455. says to use the file `altmake' as the makefile.
  5456.  
  5457.    If you use the `-f' flag several times and follow each `-f' with an
  5458. argument, all the specified files are used jointly as makefiles.
  5459.  
  5460.    If you do not use the `-f' or `--file' flag, the default is to try
  5461. `GNUmakefile', `makefile', and `Makefile', in that order, and use the
  5462. first of these three which exists or can be made (*note Writing
  5463. Makefiles: Makefiles.).
  5464.  
  5465. 
  5466. File: make,  Node: Goals,  Next: Instead of Execution,  Prev: Makefile Arguments,  Up: Running
  5467.  
  5468. 9.2 Arguments to Specify the Goals
  5469. ==================================
  5470.  
  5471. The "goals" are the targets that `make' should strive ultimately to
  5472. update.  Other targets are updated as well if they appear as
  5473. prerequisites of goals, or prerequisites of prerequisites of goals, etc.
  5474.  
  5475.    By default, the goal is the first target in the makefile (not
  5476. counting targets that start with a period).  Therefore, makefiles are
  5477. usually written so that the first target is for compiling the entire
  5478. program or programs they describe.  If the first rule in the makefile
  5479. has several targets, only the first target in the rule becomes the
  5480. default goal, not the whole list.
  5481.  
  5482.    You can specify a different goal or goals with arguments to `make'.
  5483. Use the name of the goal as an argument.  If you specify several goals,
  5484. `make' processes each of them in turn, in the order you name them.
  5485.  
  5486.    Any target in the makefile may be specified as a goal (unless it
  5487. starts with `-' or contains an `=', in which case it will be parsed as
  5488. a switch or variable definition, respectively).  Even targets not in
  5489. the makefile may be specified, if `make' can find implicit rules that
  5490. say how to make them.
  5491.  
  5492.    `Make' will set the special variable `MAKECMDGOALS' to the list of
  5493. goals you specified on the command line.  If no goals were given on the
  5494. command line, this variable is empty.  Note that this variable should
  5495. be used only in special circumstances.
  5496.  
  5497.    An example of appropriate use is to avoid including `.d' files
  5498. during `clean' rules (*note Automatic Prerequisites::), so `make' won't
  5499. create them only to immediately remove them again:
  5500.  
  5501.      sources = foo.c bar.c
  5502.  
  5503.      ifneq ($(MAKECMDGOALS),clean)
  5504.      include $(sources:.c=.d)
  5505.      endif
  5506.  
  5507.    One use of specifying a goal is if you want to compile only a part of
  5508. the program, or only one of several programs.  Specify as a goal each
  5509. file that you wish to remake.  For example, consider a directory
  5510. containing several programs, with a makefile that starts like this:
  5511.  
  5512.      .PHONY: all
  5513.      all: size nm ld ar as
  5514.  
  5515.    If you are working on the program `size', you might want to say
  5516. `make size' so that only the files of that program are recompiled.
  5517.  
  5518.    Another use of specifying a goal is to make files that are not
  5519. normally made.  For example, there may be a file of debugging output,
  5520. or a version of the program that is compiled specially for testing,
  5521. which has a rule in the makefile but is not a prerequisite of the
  5522. default goal.
  5523.  
  5524.    Another use of specifying a goal is to run the commands associated
  5525. with a phony target (*note Phony Targets::) or empty target (*note
  5526. Empty Target Files to Record Events: Empty Targets.).  Many makefiles
  5527. contain a phony target named `clean' which deletes everything except
  5528. source files.  Naturally, this is done only if you request it
  5529. explicitly with `make clean'.  Following is a list of typical phony and
  5530. empty target names.  *Note Standard Targets::, for a detailed list of
  5531. all the standard target names which GNU software packages use.
  5532.  
  5533. `all'
  5534.      Make all the top-level targets the makefile knows about.
  5535.  
  5536. `clean'
  5537.      Delete all files that are normally created by running `make'.
  5538.  
  5539. `mostlyclean'
  5540.      Like `clean', but may refrain from deleting a few files that people
  5541.      normally don't want to recompile.  For example, the `mostlyclean'
  5542.      target for GCC does not delete `libgcc.a', because recompiling it
  5543.      is rarely necessary and takes a lot of time.
  5544.  
  5545. `distclean'
  5546. `realclean'
  5547. `clobber'
  5548.      Any of these targets might be defined to delete _more_ files than
  5549.      `clean' does.  For example, this would delete configuration files
  5550.      or links that you would normally create as preparation for
  5551.      compilation, even if the makefile itself cannot create these files.
  5552.  
  5553. `install'
  5554.      Copy the executable file into a directory that users typically
  5555.      search for commands; copy any auxiliary files that the executable
  5556.      uses into the directories where it will look for them.
  5557.  
  5558. `print'
  5559.      Print listings of the source files that have changed.
  5560.  
  5561. `tar'
  5562.      Create a tar file of the source files.
  5563.  
  5564. `shar'
  5565.      Create a shell archive (shar file) of the source files.
  5566.  
  5567. `dist'
  5568.      Create a distribution file of the source files.  This might be a
  5569.      tar file, or a shar file, or a compressed version of one of the
  5570.      above, or even more than one of the above.
  5571.  
  5572. `TAGS'
  5573.      Update a tags table for this program.
  5574.  
  5575. `check'
  5576. `test'
  5577.      Perform self tests on the program this makefile builds.
  5578.  
  5579. 
  5580. File: make,  Node: Instead of Execution,  Next: Avoiding Compilation,  Prev: Goals,  Up: Running
  5581.  
  5582. 9.3 Instead of Executing the Commands
  5583. =====================================
  5584.  
  5585. The makefile tells `make' how to tell whether a target is up to date,
  5586. and how to update each target.  But updating the targets is not always
  5587. what you want.  Certain options specify other activities for `make'.
  5588.  
  5589. `-n'
  5590. `--just-print'
  5591. `--dry-run'
  5592. `--recon'
  5593.      "No-op".  The activity is to print what commands would be used to
  5594.      make the targets up to date, but not actually execute them.
  5595.  
  5596. `-t'
  5597. `--touch'
  5598.      "Touch".  The activity is to mark the targets as up to date without
  5599.      actually changing them.  In other words, `make' pretends to compile
  5600.      the targets but does not really change their contents.
  5601.  
  5602. `-q'
  5603. `--question'
  5604.      "Question".  The activity is to find out silently whether the
  5605.      targets are up to date already; but execute no commands in either
  5606.      case.  In other words, neither compilation nor output will occur.
  5607.  
  5608. `-W FILE'
  5609. `--what-if=FILE'
  5610. `--assume-new=FILE'
  5611. `--new-file=FILE'
  5612.      "What if".  Each `-W' flag is followed by a file name.  The given
  5613.      files' modification times are recorded by `make' as being the
  5614.      present time, although the actual modification times remain the
  5615.      same.  You can use the `-W' flag in conjunction with the `-n' flag
  5616.      to see what would happen if you were to modify specific files.
  5617.  
  5618.    With the `-n' flag, `make' prints the commands that it would
  5619. normally execute but does not execute them.
  5620.  
  5621.    With the `-t' flag, `make' ignores the commands in the rules and
  5622. uses (in effect) the command `touch' for each target that needs to be
  5623. remade.  The `touch' command is also printed, unless `-s' or `.SILENT'
  5624. is used.  For speed, `make' does not actually invoke the program
  5625. `touch'.  It does the work directly.
  5626.  
  5627.    With the `-q' flag, `make' prints nothing and executes no commands,
  5628. but the exit status code it returns is zero if and only if the targets
  5629. to be considered are already up to date.  If the exit status is one,
  5630. then some updating needs to be done.  If `make' encounters an error,
  5631. the exit status is two, so you can distinguish an error from a target
  5632. that is not up to date.
  5633.  
  5634.    It is an error to use more than one of these three flags in the same
  5635. invocation of `make'.
  5636.  
  5637.    The `-n', `-t', and `-q' options do not affect command lines that
  5638. begin with `+' characters or contain the strings `$(MAKE)' or
  5639. `${MAKE}'.  Note that only the line containing the `+' character or the
  5640. strings `$(MAKE)' or `${MAKE}' is run regardless of these options.
  5641. Other lines in the same rule are not run unless they too begin with `+'
  5642. or contain `$(MAKE)' or `${MAKE}' (*Note How the `MAKE' Variable Works:
  5643. MAKE Variable.)
  5644.  
  5645.    The `-W' flag provides two features:
  5646.  
  5647.    * If you also use the `-n' or `-q' flag, you can see what `make'
  5648.      would do if you were to modify some files.
  5649.  
  5650.    * Without the `-n' or `-q' flag, when `make' is actually executing
  5651.      commands, the `-W' flag can direct `make' to act as if some files
  5652.      had been modified, without actually modifying the files.
  5653.  
  5654.    Note that the options `-p' and `-v' allow you to obtain other
  5655. information about `make' or about the makefiles in use (*note Summary
  5656. of Options: Options Summary.).
  5657.  
  5658. 
  5659. File: make,  Node: Avoiding Compilation,  Next: Overriding,  Prev: Instead of Execution,  Up: Running
  5660.  
  5661. 9.4 Avoiding Recompilation of Some Files
  5662. ========================================
  5663.  
  5664. Sometimes you may have changed a source file but you do not want to
  5665. recompile all the files that depend on it.  For example, suppose you add
  5666. a macro or a declaration to a header file that many other files depend
  5667. on.  Being conservative, `make' assumes that any change in the header
  5668. file requires recompilation of all dependent files, but you know that
  5669. they do not need to be recompiled and you would rather not waste the
  5670. time waiting for them to compile.
  5671.  
  5672.    If you anticipate the problem before changing the header file, you
  5673. can use the `-t' flag.  This flag tells `make' not to run the commands
  5674. in the rules, but rather to mark the target up to date by changing its
  5675. last-modification date.  You would follow this procedure:
  5676.  
  5677.   1. Use the command `make' to recompile the source files that really
  5678.      need recompilation, ensuring that the object files are up-to-date
  5679.      before you begin.
  5680.  
  5681.   2. Make the changes in the header files.
  5682.  
  5683.   3. Use the command `make -t' to mark all the object files as up to
  5684.      date.  The next time you run `make', the changes in the header
  5685.      files will not cause any recompilation.
  5686.  
  5687.    If you have already changed the header file at a time when some files
  5688. do need recompilation, it is too late to do this.  Instead, you can use
  5689. the `-o FILE' flag, which marks a specified file as "old" (*note
  5690. Summary of Options: Options Summary.).  This means that the file itself
  5691. will not be remade, and nothing else will be remade on its account.
  5692. Follow this procedure:
  5693.  
  5694.   1. Recompile the source files that need compilation for reasons
  5695.      independent of the particular header file, with `make -o
  5696.      HEADERFILE'.  If several header files are involved, use a separate
  5697.      `-o' option for each header file.
  5698.  
  5699.   2. Touch all the object files with `make -t'.
  5700.  
  5701. 
  5702. File: make,  Node: Overriding,  Next: Testing,  Prev: Avoiding Compilation,  Up: Running
  5703.  
  5704. 9.5 Overriding Variables
  5705. ========================
  5706.  
  5707. An argument that contains `=' specifies the value of a variable: `V=X'
  5708. sets the value of the variable V to X.  If you specify a value in this
  5709. way, all ordinary assignments of the same variable in the makefile are
  5710. ignored; we say they have been "overridden" by the command line
  5711. argument.
  5712.  
  5713.    The most common way to use this facility is to pass extra flags to
  5714. compilers.  For example, in a properly written makefile, the variable
  5715. `CFLAGS' is included in each command that runs the C compiler, so a
  5716. file `foo.c' would be compiled something like this:
  5717.  
  5718.      cc -c $(CFLAGS) foo.c
  5719.  
  5720.    Thus, whatever value you set for `CFLAGS' affects each compilation
  5721. that occurs.  The makefile probably specifies the usual value for
  5722. `CFLAGS', like this:
  5723.  
  5724.      CFLAGS=-g
  5725.  
  5726.    Each time you run `make', you can override this value if you wish.
  5727. For example, if you say `make CFLAGS='-g -O'', each C compilation will
  5728. be done with `cc -c -g -O'.  (This also illustrates how you can use
  5729. quoting in the shell to enclose spaces and other special characters in
  5730. the value of a variable when you override it.)
  5731.  
  5732.    The variable `CFLAGS' is only one of many standard variables that
  5733. exist just so that you can change them this way.  *Note Variables Used
  5734. by Implicit Rules: Implicit Variables, for a complete list.
  5735.  
  5736.    You can also program the makefile to look at additional variables of
  5737. your own, giving the user the ability to control other aspects of how
  5738. the makefile works by changing the variables.
  5739.  
  5740.    When you override a variable with a command argument, you can define
  5741. either a recursively-expanded variable or a simply-expanded variable.
  5742. The examples shown above make a recursively-expanded variable; to make a
  5743. simply-expanded variable, write `:=' instead of `='.  But, unless you
  5744. want to include a variable reference or function call in the _value_
  5745. that you specify, it makes no difference which kind of variable you
  5746. create.
  5747.  
  5748.    There is one way that the makefile can change a variable that you
  5749. have overridden.  This is to use the `override' directive, which is a
  5750. line that looks like this: `override VARIABLE = VALUE' (*note The
  5751. `override' Directive: Override Directive.).
  5752.  
  5753. 
  5754. File: make,  Node: Testing,  Next: Options Summary,  Prev: Overriding,  Up: Running
  5755.  
  5756. 9.6 Testing the Compilation of a Program
  5757. ========================================
  5758.  
  5759. Normally, when an error happens in executing a shell command, `make'
  5760. gives up immediately, returning a nonzero status.  No further commands
  5761. are executed for any target.  The error implies that the goal cannot be
  5762. correctly remade, and `make' reports this as soon as it knows.
  5763.  
  5764.    When you are compiling a program that you have just changed, this is
  5765. not what you want.  Instead, you would rather that `make' try compiling
  5766. every file that can be tried, to show you as many compilation errors as
  5767. possible.
  5768.  
  5769.    On these occasions, you should use the `-k' or `--keep-going' flag.
  5770. This tells `make' to continue to consider the other prerequisites of
  5771. the pending targets, remaking them if necessary, before it gives up and
  5772. returns nonzero status.  For example, after an error in compiling one
  5773. object file, `make -k' will continue compiling other object files even
  5774. though it already knows that linking them will be impossible.  In
  5775. addition to continuing after failed shell commands, `make -k' will
  5776. continue as much as possible after discovering that it does not know
  5777. how to make a target or prerequisite file.  This will always cause an
  5778. error message, but without `-k', it is a fatal error (*note Summary of
  5779. Options: Options Summary.).
  5780.  
  5781.    The usual behavior of `make' assumes that your purpose is to get the
  5782. goals up to date; once `make' learns that this is impossible, it might
  5783. as well report the failure immediately.  The `-k' flag says that the
  5784. real purpose is to test as much as possible of the changes made in the
  5785. program, perhaps to find several independent problems so that you can
  5786. correct them all before the next attempt to compile.  This is why Emacs'
  5787. `M-x compile' command passes the `-k' flag by default.
  5788.  
  5789. 
  5790. File: make,  Node: Options Summary,  Prev: Testing,  Up: Running
  5791.  
  5792. 9.7 Summary of Options
  5793. ======================
  5794.  
  5795. Here is a table of all the options `make' understands:
  5796.  
  5797. `-b'
  5798. `-m'
  5799.      These options are ignored for compatibility with other versions of
  5800.      `make'.
  5801.  
  5802. `-B'
  5803. `--always-make'
  5804.      Consider all targets out-of-date.  GNU `make' proceeds to consider
  5805.      targets and their prerequisites using the normal algorithms;
  5806.      however, all these targets are remade, regardless of the status of
  5807.      their prerequisites.
  5808.  
  5809. `-C DIR'
  5810. `--directory=DIR'
  5811.      Change to directory DIR before reading the makefiles.  If multiple
  5812.      `-C' options are specified, each is interpreted relative to the
  5813.      previous one: `-C / -C etc' is equivalent to `-C /etc'.  This is
  5814.      typically used with recursive invocations of `make' (*note
  5815.      Recursive Use of `make': Recursion.).
  5816.  
  5817. `-d'
  5818.      Print debugging information in addition to normal processing.  The
  5819.      debugging information says which files are being considered for
  5820.      remaking, which file-times are being compared and with what
  5821.      results, which files actually need to be remade, which implicit
  5822.      rules are considered and which are applied--everything interesting
  5823.      about how `make' decides what to do.  The `-d' option is
  5824.      equivalent to `--debug=a' (see below).
  5825.  
  5826. `--debug[=OPTIONS]'
  5827.      Print debugging information in addition to normal processing.
  5828.      Various levels and types of output can be chosen.  With no
  5829.      arguments, print the "basic" level of debugging.  Possible
  5830.      arguments are below; only the first character is considered, and
  5831.      values must be comma- or space-separated.
  5832.  
  5833.     `a (all)'
  5834.           All types of debugging output are enabled.  This is
  5835.           equivalent to using `-d'.
  5836.  
  5837.     `b (basic)'
  5838.           Basic debugging prints each target that was found to be
  5839.           out-of-date, and whether the build was successful or not.
  5840.  
  5841.     `v (verbose)'
  5842.           A level above `basic'; includes messages about which
  5843.           makefiles were parsed, prerequisites that did not need to be
  5844.           rebuilt, etc.  This option also enables `basic' messages.
  5845.  
  5846.     `i (implicit)'
  5847.           Prints messages describing the implicit rule searches for
  5848.           each target.  This option also enables `basic' messages.
  5849.  
  5850.     `j (jobs)'
  5851.           Prints messages giving details on the invocation of specific
  5852.           subcommands.
  5853.  
  5854.     `m (makefile)'
  5855.           By default, the above messages are not enabled while trying
  5856.           to remake the makefiles.  This option enables messages while
  5857.           rebuilding makefiles, too.  Note that the `all' option does
  5858.           enable this option.  This option also enables `basic'
  5859.           messages.
  5860.  
  5861. `-e'
  5862. `--environment-overrides'
  5863.      Give variables taken from the environment precedence over
  5864.      variables from makefiles.  *Note Variables from the Environment:
  5865.      Environment.
  5866.  
  5867. `-f FILE'
  5868. `--file=FILE'
  5869. `--makefile=FILE'
  5870.      Read the file named FILE as a makefile.  *Note Writing Makefiles:
  5871.      Makefiles.
  5872.  
  5873. `-h'
  5874. `--help'
  5875.      Remind you of the options that `make' understands and then exit.
  5876.  
  5877. `-i'
  5878. `--ignore-errors'
  5879.      Ignore all errors in commands executed to remake files.  *Note
  5880.      Errors in Commands: Errors.
  5881.  
  5882. `-I DIR'
  5883. `--include-dir=DIR'
  5884.      Specifies a directory DIR to search for included makefiles.  *Note
  5885.      Including Other Makefiles: Include.  If several `-I' options are
  5886.      used to specify several directories, the directories are searched
  5887.      in the order specified.
  5888.  
  5889. `-j [JOBS]'
  5890. `--jobs[=JOBS]'
  5891.      Specifies the number of jobs (commands) to run simultaneously.
  5892.      With no argument, `make' runs as many jobs simultaneously as
  5893.      possible.  If there is more than one `-j' option, the last one is
  5894.      effective.  *Note Parallel Execution: Parallel, for more
  5895.      information on how commands are run.  Note that this option is
  5896.      ignored on MS-DOS.
  5897.  
  5898. `-k'
  5899. `--keep-going'
  5900.      Continue as much as possible after an error.  While the target that
  5901.      failed, and those that depend on it, cannot be remade, the other
  5902.      prerequisites of these targets can be processed all the same.
  5903.      *Note Testing the Compilation of a Program: Testing.
  5904.  
  5905. `-l [LOAD]'
  5906. `--load-average[=LOAD]'
  5907. `--max-load[=LOAD]'
  5908.      Specifies that no new jobs (commands) should be started if there
  5909.      are other jobs running and the load average is at least LOAD (a
  5910.      floating-point number).  With no argument, removes a previous load
  5911.      limit.  *Note Parallel Execution: Parallel.
  5912.  
  5913. `-n'
  5914. `--just-print'
  5915. `--dry-run'
  5916. `--recon'
  5917.      Print the commands that would be executed, but do not execute them.
  5918.      *Note Instead of Executing the Commands: Instead of Execution.
  5919.  
  5920. `-o FILE'
  5921. `--old-file=FILE'
  5922. `--assume-old=FILE'
  5923.      Do not remake the file FILE even if it is older than its
  5924.      prerequisites, and do not remake anything on account of changes in
  5925.      FILE.  Essentially the file is treated as very old and its rules
  5926.      are ignored.  *Note Avoiding Recompilation of Some Files: Avoiding
  5927.      Compilation.
  5928.  
  5929. `-p'
  5930. `--print-data-base'
  5931.      Print the data base (rules and variable values) that results from
  5932.      reading the makefiles; then execute as usual or as otherwise
  5933.      specified.  This also prints the version information given by the
  5934.      `-v' switch (see below).  To print the data base without trying to
  5935.      remake any files, use `make -qp'.  To print the data base of
  5936.      predefined rules and variables, use `make -p -f /dev/null'.  The
  5937.      data base output contains filename and linenumber information for
  5938.      command and variable definitions, so it can be a useful debugging
  5939.      tool in complex environments.
  5940.  
  5941. `-q'
  5942. `--question'
  5943.      "Question mode".  Do not run any commands, or print anything; just
  5944.      return an exit status that is zero if the specified targets are
  5945.      already up to date, one if any remaking is required, or two if an
  5946.      error is encountered.  *Note Instead of Executing the Commands:
  5947.      Instead of Execution.
  5948.  
  5949. `-r'
  5950. `--no-builtin-rules'
  5951.      Eliminate use of the built-in implicit rules (*note Using Implicit
  5952.      Rules: Implicit Rules.).  You can still define your own by writing
  5953.      pattern rules (*note Defining and Redefining Pattern Rules:
  5954.      Pattern Rules.).  The `-r' option also clears out the default list
  5955.      of suffixes for suffix rules (*note Old-Fashioned Suffix Rules:
  5956.      Suffix Rules.).  But you can still define your own suffixes with a
  5957.      rule for `.SUFFIXES', and then define your own suffix rules.  Note
  5958.      that only _rules_ are affected by the `-r' option; default
  5959.      variables remain in effect (*note Variables Used by Implicit
  5960.      Rules: Implicit Variables.); see the `-R' option below.
  5961.  
  5962. `-R'
  5963. `--no-builtin-variables'
  5964.      Eliminate use of the built-in rule-specific variables (*note
  5965.      Variables Used by Implicit Rules: Implicit Variables.).  You can
  5966.      still define your own, of course.  The `-R' option also
  5967.      automatically enables the `-r' option (see above), since it
  5968.      doesn't make sense to have implicit rules without any definitions
  5969.      for the variables that they use.
  5970.  
  5971. `-s'
  5972. `--silent'
  5973. `--quiet'
  5974.      Silent operation; do not print the commands as they are executed.
  5975.      *Note Command Echoing: Echoing.
  5976.  
  5977. `-S'
  5978. `--no-keep-going'
  5979. `--stop'
  5980.      Cancel the effect of the `-k' option.  This is never necessary
  5981.      except in a recursive `make' where `-k' might be inherited from
  5982.      the top-level `make' via `MAKEFLAGS' (*note Recursive Use of
  5983.      `make': Recursion.)  or if you set `-k' in `MAKEFLAGS' in your
  5984.      environment.
  5985.  
  5986. `-t'
  5987. `--touch'
  5988.      Touch files (mark them up to date without really changing them)
  5989.      instead of running their commands.  This is used to pretend that
  5990.      the commands were done, in order to fool future invocations of
  5991.      `make'.  *Note Instead of Executing the Commands: Instead of
  5992.      Execution.
  5993.  
  5994. `-v'
  5995. `--version'
  5996.      Print the version of the `make' program plus a copyright, a list
  5997.      of authors, and a notice that there is no warranty; then exit.
  5998.  
  5999. `-w'
  6000. `--print-directory'
  6001.      Print a message containing the working directory both before and
  6002.      after executing the makefile.  This may be useful for tracking
  6003.      down errors from complicated nests of recursive `make' commands.
  6004.      *Note Recursive Use of `make': Recursion.  (In practice, you
  6005.      rarely need to specify this option since `make' does it for you;
  6006.      see *Note The `--print-directory' Option: -w Option.)
  6007.  
  6008. `--no-print-directory'
  6009.      Disable printing of the working directory under `-w'.  This option
  6010.      is useful when `-w' is turned on automatically, but you do not
  6011.      want to see the extra messages.  *Note The `--print-directory'
  6012.      Option: -w Option.
  6013.  
  6014. `-W FILE'
  6015. `--what-if=FILE'
  6016. `--new-file=FILE'
  6017. `--assume-new=FILE'
  6018.      Pretend that the target FILE has just been modified.  When used
  6019.      with the `-n' flag, this shows you what would happen if you were
  6020.      to modify that file.  Without `-n', it is almost the same as
  6021.      running a `touch' command on the given file before running `make',
  6022.      except that the modification time is changed only in the
  6023.      imagination of `make'.  *Note Instead of Executing the Commands:
  6024.      Instead of Execution.
  6025.  
  6026. `--warn-undefined-variables'
  6027.      Issue a warning message whenever `make' sees a reference to an
  6028.      undefined variable.  This can be helpful when you are trying to
  6029.      debug makefiles which use variables in complex ways.
  6030.  
  6031. 
  6032. File: make,  Node: Implicit Rules,  Next: Archives,  Prev: Running,  Up: Top
  6033.  
  6034. 10 Using Implicit Rules
  6035. ***********************
  6036.  
  6037. Certain standard ways of remaking target files are used very often.  For
  6038. example, one customary way to make an object file is from a C source
  6039. file using the C compiler, `cc'.
  6040.  
  6041.    "Implicit rules" tell `make' how to use customary techniques so that
  6042. you do not have to specify them in detail when you want to use them.
  6043. For example, there is an implicit rule for C compilation.  File names
  6044. determine which implicit rules are run.  For example, C compilation
  6045. typically takes a `.c' file and makes a `.o' file.  So `make' applies
  6046. the implicit rule for C compilation when it sees this combination of
  6047. file name endings.
  6048.  
  6049.    A chain of implicit rules can apply in sequence; for example, `make'
  6050. will remake a `.o' file from a `.y' file by way of a `.c' file.
  6051.  
  6052.    The built-in implicit rules use several variables in their commands
  6053. so that, by changing the values of the variables, you can change the
  6054. way the implicit rule works.  For example, the variable `CFLAGS'
  6055. controls the flags given to the C compiler by the implicit rule for C
  6056. compilation.
  6057.  
  6058.    You can define your own implicit rules by writing "pattern rules".
  6059.  
  6060.    "Suffix rules" are a more limited way to define implicit rules.
  6061. Pattern rules are more general and clearer, but suffix rules are
  6062. retained for compatibility.
  6063.  
  6064. * Menu:
  6065.  
  6066. * Using Implicit::              How to use an existing implicit rule
  6067.                                   to get the commands for updating a file.
  6068. * Catalogue of Rules::          A list of built-in implicit rules.
  6069. * Implicit Variables::          How to change what predefined rules do.
  6070. * Chained Rules::               How to use a chain of implicit rules.
  6071. * Pattern Rules::               How to define new implicit rules.
  6072. * Last Resort::                 How to defining commands for rules
  6073.                                   which cannot find any.
  6074. * Suffix Rules::                The old-fashioned style of implicit rule.
  6075. * Implicit Rule Search::        The precise algorithm for applying
  6076.                                   implicit rules.
  6077.  
  6078. 
  6079. File: make,  Node: Using Implicit,  Next: Catalogue of Rules,  Prev: Implicit Rules,  Up: Implicit Rules
  6080.  
  6081. 10.1 Using Implicit Rules
  6082. =========================
  6083.  
  6084. To allow `make' to find a customary method for updating a target file,
  6085. all you have to do is refrain from specifying commands yourself.  Either
  6086. write a rule with no command lines, or don't write a rule at all.  Then
  6087. `make' will figure out which implicit rule to use based on which kind
  6088. of source file exists or can be made.
  6089.  
  6090.    For example, suppose the makefile looks like this:
  6091.  
  6092.      foo : foo.o bar.o
  6093.              cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS)
  6094.  
  6095. Because you mention `foo.o' but do not give a rule for it, `make' will
  6096. automatically look for an implicit rule that tells how to update it.
  6097. This happens whether or not the file `foo.o' currently exists.
  6098.  
  6099.    If an implicit rule is found, it can supply both commands and one or
  6100. more prerequisites (the source files).  You would want to write a rule
  6101. for `foo.o' with no command lines if you need to specify additional
  6102. prerequisites, such as header files, that the implicit rule cannot
  6103. supply.
  6104.  
  6105.    Each implicit rule has a target pattern and prerequisite patterns.
  6106. There may be many implicit rules with the same target pattern.  For
  6107. example, numerous rules make `.o' files: one, from a `.c' file with the
  6108. C compiler; another, from a `.p' file with the Pascal compiler; and so
  6109. on.  The rule that actually applies is the one whose prerequisites
  6110. exist or can be made.  So, if you have a file `foo.c', `make' will run
  6111. the C compiler; otherwise, if you have a file `foo.p', `make' will run
  6112. the Pascal compiler; and so on.
  6113.  
  6114.    Of course, when you write the makefile, you know which implicit rule
  6115. you want `make' to use, and you know it will choose that one because you
  6116. know which possible prerequisite files are supposed to exist.  *Note
  6117. Catalogue of Implicit Rules: Catalogue of Rules, for a catalogue of all
  6118. the predefined implicit rules.
  6119.  
  6120.    Above, we said an implicit rule applies if the required
  6121. prerequisites "exist or can be made".  A file "can be made" if it is
  6122. mentioned explicitly in the makefile as a target or a prerequisite, or
  6123. if an implicit rule can be recursively found for how to make it.  When
  6124. an implicit prerequisite is the result of another implicit rule, we say
  6125. that "chaining" is occurring.  *Note Chains of Implicit Rules: Chained
  6126. Rules.
  6127.  
  6128.    In general, `make' searches for an implicit rule for each target, and
  6129. for each double-colon rule, that has no commands.  A file that is
  6130. mentioned only as a prerequisite is considered a target whose rule
  6131. specifies nothing, so implicit rule search happens for it.  *Note
  6132. Implicit Rule Search Algorithm: Implicit Rule Search, for the details
  6133. of how the search is done.
  6134.  
  6135.    Note that explicit prerequisites do not influence implicit rule
  6136. search.  For example, consider this explicit rule:
  6137.  
  6138.      foo.o: foo.p
  6139.  
  6140. The prerequisite on `foo.p' does not necessarily mean that `make' will
  6141. remake `foo.o' according to the implicit rule to make an object file, a
  6142. `.o' file, from a Pascal source file, a `.p' file.  For example, if
  6143. `foo.c' also exists, the implicit rule to make an object file from a C
  6144. source file is used instead, because it appears before the Pascal rule
  6145. in the list of predefined implicit rules (*note Catalogue of Implicit
  6146. Rules: Catalogue of Rules.).
  6147.  
  6148.    If you do not want an implicit rule to be used for a target that has
  6149. no commands, you can give that target empty commands by writing a
  6150. semicolon (*note Defining Empty Commands: Empty Commands.).
  6151.  
  6152. 
  6153. File: make,  Node: Catalogue of Rules,  Next: Implicit Variables,  Prev: Using Implicit,  Up: Implicit Rules
  6154.  
  6155. 10.2 Catalogue of Implicit Rules
  6156. ================================
  6157.  
  6158. Here is a catalogue of predefined implicit rules which are always
  6159. available unless the makefile explicitly overrides or cancels them.
  6160. *Note Canceling Implicit Rules: Canceling Rules, for information on
  6161. canceling or overriding an implicit rule.  The `-r' or
  6162. `--no-builtin-rules' option cancels all predefined rules.
  6163.  
  6164.    Not all of these rules will always be defined, even when the `-r'
  6165. option is not given.  Many of the predefined implicit rules are
  6166. implemented in `make' as suffix rules, so which ones will be defined
  6167. depends on the "suffix list" (the list of prerequisites of the special
  6168. target `.SUFFIXES').  The default suffix list is: `.out', `.a', `.ln',
  6169. `.o', `.c', `.cc', `.C', `.p', `.f', `.F', `.r', `.y', `.l', `.s',
  6170. `.S', `.mod', `.sym', `.def', `.h', `.info', `.dvi', `.tex', `.texinfo',
  6171. `.texi', `.txinfo', `.w', `.ch' `.web', `.sh', `.elc', `.el'.  All of
  6172. the implicit rules described below whose prerequisites have one of
  6173. these suffixes are actually suffix rules.  If you modify the suffix
  6174. list, the only predefined suffix rules in effect will be those named by
  6175. one or two of the suffixes that are on the list you specify; rules
  6176. whose suffixes fail to be on the list are disabled.  *Note
  6177. Old-Fashioned Suffix Rules: Suffix Rules, for full details on suffix
  6178. rules.
  6179.  
  6180. Compiling C programs
  6181.      `N.o' is made automatically from `N.c' with a command of the form
  6182.      `$(CC) -c $(CPPFLAGS) $(CFLAGS)'.
  6183.  
  6184. Compiling C++ programs
  6185.      `N.o' is made automatically from `N.cc' or `N.C' with a command of
  6186.      the form `$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)'.  We encourage you to
  6187.      use the suffix `.cc' for C++ source files instead of `.C'.
  6188.  
  6189. Compiling Pascal programs
  6190.      `N.o' is made automatically from `N.p' with the command `$(PC) -c
  6191.      $(PFLAGS)'.
  6192.  
  6193. Compiling Fortran and Ratfor programs
  6194.      `N.o' is made automatically from `N.r', `N.F' or `N.f' by running
  6195.      the Fortran compiler.  The precise command used is as follows:
  6196.  
  6197.     `.f'
  6198.           `$(FC) -c $(FFLAGS)'.
  6199.  
  6200.     `.F'
  6201.           `$(FC) -c $(FFLAGS) $(CPPFLAGS)'.
  6202.  
  6203.     `.r'
  6204.           `$(FC) -c $(FFLAGS) $(RFLAGS)'.
  6205.  
  6206. Preprocessing Fortran and Ratfor programs
  6207.      `N.f' is made automatically from `N.r' or `N.F'.  This rule runs
  6208.      just the preprocessor to convert a Ratfor or preprocessable
  6209.      Fortran program into a strict Fortran program.  The precise
  6210.      command used is as follows:
  6211.  
  6212.     `.F'
  6213.           `$(FC) -F $(CPPFLAGS) $(FFLAGS)'.
  6214.  
  6215.     `.r'
  6216.           `$(FC) -F $(FFLAGS) $(RFLAGS)'.
  6217.  
  6218. Compiling Modula-2 programs
  6219.      `N.sym' is made from `N.def' with a command of the form `$(M2C)
  6220.      $(M2FLAGS) $(DEFFLAGS)'.  `N.o' is made from `N.mod'; the form is:
  6221.      `$(M2C) $(M2FLAGS) $(MODFLAGS)'.
  6222.  
  6223. Assembling and preprocessing assembler programs
  6224.      `N.o' is made automatically from `N.s' by running the assembler,
  6225.      `as'.  The precise command is `$(AS) $(ASFLAGS)'.
  6226.  
  6227.      `N.s' is made automatically from `N.S' by running the C
  6228.      preprocessor, `cpp'.  The precise command is `$(CPP) $(CPPFLAGS)'.
  6229.  
  6230. Linking a single object file
  6231.      `N' is made automatically from `N.o' by running the linker
  6232.      (usually called `ld') via the C compiler.  The precise command
  6233.      used is `$(CC) $(LDFLAGS) N.o $(LOADLIBES) $(LDLIBS)'.
  6234.  
  6235.      This rule does the right thing for a simple program with only one
  6236.      source file.  It will also do the right thing if there are multiple
  6237.      object files (presumably coming from various other source files),
  6238.      one of which has a name matching that of the executable file.
  6239.      Thus,
  6240.  
  6241.           x: y.o z.o
  6242.  
  6243.      when `x.c', `y.c' and `z.c' all exist will execute:
  6244.  
  6245.           cc -c x.c -o x.o
  6246.           cc -c y.c -o y.o
  6247.           cc -c z.c -o z.o
  6248.           cc x.o y.o z.o -o x
  6249.           rm -f x.o
  6250.           rm -f y.o
  6251.           rm -f z.o
  6252.  
  6253.      In more complicated cases, such as when there is no object file
  6254.      whose name derives from the executable file name, you must write
  6255.      an explicit command for linking.
  6256.  
  6257.      Each kind of file automatically made into `.o' object files will
  6258.      be automatically linked by using the compiler (`$(CC)', `$(FC)' or
  6259.      `$(PC)'; the C compiler `$(CC)' is used to assemble `.s' files)
  6260.      without the `-c' option.  This could be done by using the `.o'
  6261.      object files as intermediates, but it is faster to do the
  6262.      compiling and linking in one step, so that's how it's done.
  6263.  
  6264. Yacc for C programs
  6265.      `N.c' is made automatically from `N.y' by running Yacc with the
  6266.      command `$(YACC) $(YFLAGS)'.
  6267.  
  6268. Lex for C programs
  6269.      `N.c' is made automatically from `N.l' by running Lex.  The actual
  6270.      command is `$(LEX) $(LFLAGS)'.
  6271.  
  6272. Lex for Ratfor programs
  6273.      `N.r' is made automatically from `N.l' by running Lex.  The actual
  6274.      command is `$(LEX) $(LFLAGS)'.
  6275.  
  6276.      The convention of using the same suffix `.l' for all Lex files
  6277.      regardless of whether they produce C code or Ratfor code makes it
  6278.      impossible for `make' to determine automatically which of the two
  6279.      languages you are using in any particular case.  If `make' is
  6280.      called upon to remake an object file from a `.l' file, it must
  6281.      guess which compiler to use.  It will guess the C compiler, because
  6282.      that is more common.  If you are using Ratfor, make sure `make'
  6283.      knows this by mentioning `N.r' in the makefile.  Or, if you are
  6284.      using Ratfor exclusively, with no C files, remove `.c' from the
  6285.      list of implicit rule suffixes with:
  6286.  
  6287.           .SUFFIXES:
  6288.           .SUFFIXES: .o .r .f .l ...
  6289.  
  6290. Making Lint Libraries from C, Yacc, or Lex programs
  6291.      `N.ln' is made from `N.c' by running `lint'.  The precise command
  6292.      is `$(LINT) $(LINTFLAGS) $(CPPFLAGS) -i'.  The same command is
  6293.      used on the C code produced from `N.y' or `N.l'.
  6294.  
  6295. TeX and Web
  6296.      `N.dvi' is made from `N.tex' with the command `$(TEX)'.  `N.tex'
  6297.      is made from `N.web' with `$(WEAVE)', or from `N.w' (and from
  6298.      `N.ch' if it exists or can be made) with `$(CWEAVE)'.  `N.p' is
  6299.      made from `N.web' with `$(TANGLE)' and `N.c' is made from `N.w'
  6300.      (and from `N.ch' if it exists or can be made) with `$(CTANGLE)'.
  6301.  
  6302. Texinfo and Info
  6303.      `N.dvi' is made from `N.texinfo', `N.texi', or `N.txinfo', with
  6304.      the command `$(TEXI2DVI) $(TEXI2DVI_FLAGS)'.  `N.info' is made from
  6305.      `N.texinfo', `N.texi', or `N.txinfo', with the command
  6306.      `$(MAKEINFO) $(MAKEINFO_FLAGS)'.
  6307.  
  6308. RCS
  6309.      Any file `N' is extracted if necessary from an RCS file named
  6310.      either `N,v' or `RCS/N,v'.  The precise command used is
  6311.      `$(CO) $(COFLAGS)'.  `N' will not be extracted from RCS if it
  6312.      already exists, even if the RCS file is newer.  The rules for RCS
  6313.      are terminal (*note Match-Anything Pattern Rules: Match-Anything
  6314.      Rules.), so RCS files cannot be generated from another source;
  6315.      they must actually exist.
  6316.  
  6317. SCCS
  6318.      Any file `N' is extracted if necessary from an SCCS file named
  6319.      either `s.N' or `SCCS/s.N'.  The precise command used is
  6320.      `$(GET) $(GFLAGS)'.  The rules for SCCS are terminal (*note
  6321.      Match-Anything Pattern Rules: Match-Anything Rules.), so SCCS
  6322.      files cannot be generated from another source; they must actually
  6323.      exist.
  6324.  
  6325.      For the benefit of SCCS, a file `N' is copied from `N.sh' and made
  6326.      executable (by everyone).  This is for shell scripts that are
  6327.      checked into SCCS.  Since RCS preserves the execution permission
  6328.      of a file, you do not need to use this feature with RCS.
  6329.  
  6330.      We recommend that you avoid using of SCCS.  RCS is widely held to
  6331.      be superior, and is also free.  By choosing free software in place
  6332.      of comparable (or inferior) proprietary software, you support the
  6333.      free software movement.
  6334.  
  6335.    Usually, you want to change only the variables listed in the table
  6336. above, which are documented in the following section.
  6337.  
  6338.    However, the commands in built-in implicit rules actually use
  6339. variables such as `COMPILE.c', `LINK.p', and `PREPROCESS.S', whose
  6340. values contain the commands listed above.
  6341.  
  6342.    `make' follows the convention that the rule to compile a `.X' source
  6343. file uses the variable `COMPILE.X'.  Similarly, the rule to produce an
  6344. executable from a `.X' file uses `LINK.X'; and the rule to preprocess a
  6345. `.X' file uses `PREPROCESS.X'.
  6346.  
  6347.    Every rule that produces an object file uses the variable
  6348. `OUTPUT_OPTION'.  `make' defines this variable either to contain `-o
  6349. $@', or to be empty, depending on a compile-time option.  You need the
  6350. `-o' option to ensure that the output goes into the right file when the
  6351. source file is in a different directory, as when using `VPATH' (*note
  6352. Directory Search::).  However, compilers on some systems do not accept
  6353. a `-o' switch for object files.  If you use such a system, and use
  6354. `VPATH', some compilations will put their output in the wrong place.  A
  6355. possible workaround for this problem is to give `OUTPUT_OPTION' the
  6356. value `; mv $*.o $@'.
  6357.  
  6358. 
  6359. File: make,  Node: Implicit Variables,  Next: Chained Rules,  Prev: Catalogue of Rules,  Up: Implicit Rules
  6360.  
  6361. 10.3 Variables Used by Implicit Rules
  6362. =====================================
  6363.  
  6364. The commands in built-in implicit rules make liberal use of certain
  6365. predefined variables.  You can alter these variables in the makefile,
  6366. with arguments to `make', or in the environment to alter how the
  6367. implicit rules work without redefining the rules themselves.  You can
  6368. cancel all variables used by implicit rules with the `-R' or
  6369. `--no-builtin-variables' option.
  6370.  
  6371.    For example, the command used to compile a C source file actually
  6372. says `$(CC) -c $(CFLAGS) $(CPPFLAGS)'.  The default values of the
  6373. variables used are `cc' and nothing, resulting in the command `cc -c'.
  6374. By redefining `CC' to `ncc', you could cause `ncc' to be used for all C
  6375. compilations performed by the implicit rule.  By redefining `CFLAGS' to
  6376. be `-g', you could pass the `-g' option to each compilation.  _All_
  6377. implicit rules that do C compilation use `$(CC)' to get the program
  6378. name for the compiler and _all_ include `$(CFLAGS)' among the arguments
  6379. given to the compiler.
  6380.  
  6381.    The variables used in implicit rules fall into two classes: those
  6382. that are names of programs (like `CC') and those that contain arguments
  6383. for the programs (like `CFLAGS').  (The "name of a program" may also
  6384. contain some command arguments, but it must start with an actual
  6385. executable program name.)  If a variable value contains more than one
  6386. argument, separate them with spaces.
  6387.  
  6388.    Here is a table of variables used as names of programs in built-in
  6389. rules:
  6390.  
  6391. `AR'
  6392.      Archive-maintaining program; default `ar'.  
  6393.  
  6394. `AS'
  6395.      Program for doing assembly; default `as'.  
  6396.  
  6397. `CC'
  6398.      Program for compiling C programs; default `cc'.  
  6399.  
  6400. `CXX'
  6401.      Program for compiling C++ programs; default `g++'.  
  6402.  
  6403. `CO'
  6404.      Program for extracting a file from RCS; default `co'.  
  6405.  
  6406. `CPP'
  6407.      Program for running the C preprocessor, with results to standard
  6408.      output; default `$(CC) -E'.
  6409.  
  6410. `FC'
  6411.      Program for compiling or preprocessing Fortran and Ratfor programs;
  6412.      default `f77'.  
  6413.  
  6414. `GET'
  6415.      Program for extracting a file from SCCS; default `get'.  
  6416.  
  6417. `LEX'
  6418.      Program to use to turn Lex grammars into C programs or Ratfor
  6419.      programs; default `lex'.  
  6420.  
  6421. `PC'
  6422.      Program for compiling Pascal programs; default `pc'.  
  6423.  
  6424. `YACC'
  6425.      Program to use to turn Yacc grammars into C programs; default
  6426.      `yacc'.  
  6427.  
  6428. `YACCR'
  6429.      Program to use to turn Yacc grammars into Ratfor programs; default
  6430.      `yacc -r'.
  6431.  
  6432. `MAKEINFO'
  6433.      Program to convert a Texinfo source file into an Info file; default
  6434.      `makeinfo'.  
  6435.  
  6436. `TEX'
  6437.      Program to make TeX DVI files from TeX source; default `tex'.  
  6438.  
  6439. `TEXI2DVI'
  6440.      Program to make TeX DVI files from Texinfo source; default
  6441.      `texi2dvi'.  
  6442.  
  6443. `WEAVE'
  6444.      Program to translate Web into TeX; default `weave'.  
  6445.  
  6446. `CWEAVE'
  6447.      Program to translate C Web into TeX; default `cweave'.  
  6448.  
  6449. `TANGLE'
  6450.      Program to translate Web into Pascal; default `tangle'.  
  6451.  
  6452. `CTANGLE'
  6453.      Program to translate C Web into C; default `ctangle'.  
  6454.  
  6455. `RM'
  6456.      Command to remove a file; default `rm -f'.  
  6457.  
  6458.    Here is a table of variables whose values are additional arguments
  6459. for the programs above.  The default values for all of these is the
  6460. empty string, unless otherwise noted.
  6461.  
  6462. `ARFLAGS'
  6463.      Flags to give the archive-maintaining program; default `rv'.
  6464.  
  6465. `ASFLAGS'
  6466.      Extra flags to give to the assembler (when explicitly invoked on a
  6467.      `.s' or `.S' file).
  6468.  
  6469. `CFLAGS'
  6470.      Extra flags to give to the C compiler.
  6471.  
  6472. `CXXFLAGS'
  6473.      Extra flags to give to the C++ compiler.
  6474.  
  6475. `COFLAGS'
  6476.      Extra flags to give to the RCS `co' program.
  6477.  
  6478. `CPPFLAGS'
  6479.      Extra flags to give to the C preprocessor and programs that use it
  6480.      (the C and Fortran compilers).
  6481.  
  6482. `FFLAGS'
  6483.      Extra flags to give to the Fortran compiler.
  6484.  
  6485. `GFLAGS'
  6486.      Extra flags to give to the SCCS `get' program.
  6487.  
  6488. `LDFLAGS'
  6489.      Extra flags to give to compilers when they are supposed to invoke
  6490.      the linker, `ld'.
  6491.  
  6492. `LFLAGS'
  6493.      Extra flags to give to Lex.
  6494.  
  6495. `PFLAGS'
  6496.      Extra flags to give to the Pascal compiler.
  6497.  
  6498. `RFLAGS'
  6499.      Extra flags to give to the Fortran compiler for Ratfor programs.
  6500.  
  6501. `YFLAGS'
  6502.      Extra flags to give to Yacc.
  6503.  
  6504. 
  6505. File: make,  Node: Chained Rules,  Next: Pattern Rules,  Prev: Implicit Variables,  Up: Implicit Rules
  6506.  
  6507. 10.4 Chains of Implicit Rules
  6508. =============================
  6509.  
  6510. Sometimes a file can be made by a sequence of implicit rules.  For
  6511. example, a file `N.o' could be made from `N.y' by running first Yacc
  6512. and then `cc'.  Such a sequence is called a "chain".
  6513.  
  6514.    If the file `N.c' exists, or is mentioned in the makefile, no
  6515. special searching is required: `make' finds that the object file can be
  6516. made by C compilation from `N.c'; later on, when considering how to
  6517. make `N.c', the rule for running Yacc is used.  Ultimately both `N.c'
  6518. and `N.o' are updated.
  6519.  
  6520.    However, even if `N.c' does not exist and is not mentioned, `make'
  6521. knows how to envision it as the missing link between `N.o' and `N.y'!
  6522. In this case, `N.c' is called an "intermediate file".  Once `make' has
  6523. decided to use the intermediate file, it is entered in the data base as
  6524. if it had been mentioned in the makefile, along with the implicit rule
  6525. that says how to create it.
  6526.  
  6527.    Intermediate files are remade using their rules just like all other
  6528. files.  But intermediate files are treated differently in two ways.
  6529.  
  6530.    The first difference is what happens if the intermediate file does
  6531. not exist.  If an ordinary file B does not exist, and `make' considers
  6532. a target that depends on B, it invariably creates B and then updates
  6533. the target from B.  But if B is an intermediate file, then `make' can
  6534. leave well enough alone.  It won't bother updating B, or the ultimate
  6535. target, unless some prerequisite of B is newer than that target or
  6536. there is some other reason to update that target.
  6537.  
  6538.    The second difference is that if `make' _does_ create B in order to
  6539. update something else, it deletes B later on after it is no longer
  6540. needed.  Therefore, an intermediate file which did not exist before
  6541. `make' also does not exist after `make'.  `make' reports the deletion
  6542. to you by printing a `rm -f' command showing which file it is deleting.
  6543.  
  6544.    Ordinarily, a file cannot be intermediate if it is mentioned in the
  6545. makefile as a target or prerequisite.  However, you can explicitly mark
  6546. a file as intermediate by listing it as a prerequisite of the special
  6547. target `.INTERMEDIATE'.  This takes effect even if the file is mentioned
  6548. explicitly in some other way.
  6549.  
  6550.    You can prevent automatic deletion of an intermediate file by
  6551. marking it as a "secondary" file.  To do this, list it as a
  6552. prerequisite of the special target `.SECONDARY'.  When a file is
  6553. secondary, `make' will not create the file merely because it does not
  6554. already exist, but `make' does not automatically delete the file.
  6555. Marking a file as secondary also marks it as intermediate.
  6556.  
  6557.    You can list the target pattern of an implicit rule (such as `%.o')
  6558. as a prerequisite of the special target `.PRECIOUS' to preserve
  6559. intermediate files made by implicit rules whose target patterns match
  6560. that file's name; see *Note Interrupts::.  
  6561.  
  6562.    A chain can involve more than two implicit rules.  For example, it is
  6563. possible to make a file `foo' from `RCS/foo.y,v' by running RCS, Yacc
  6564. and `cc'.  Then both `foo.y' and `foo.c' are intermediate files that
  6565. are deleted at the end.
  6566.  
  6567.    No single implicit rule can appear more than once in a chain.  This
  6568. means that `make' will not even consider such a ridiculous thing as
  6569. making `foo' from `foo.o.o' by running the linker twice.  This
  6570. constraint has the added benefit of preventing any infinite loop in the
  6571. search for an implicit rule chain.
  6572.  
  6573.    There are some special implicit rules to optimize certain cases that
  6574. would otherwise be handled by rule chains.  For example, making `foo'
  6575. from `foo.c' could be handled by compiling and linking with separate
  6576. chained rules, using `foo.o' as an intermediate file.  But what
  6577. actually happens is that a special rule for this case does the
  6578. compilation and linking with a single `cc' command.  The optimized rule
  6579. is used in preference to the step-by-step chain because it comes
  6580. earlier in the ordering of rules.
  6581.  
  6582. 
  6583. File: make,  Node: Pattern Rules,  Next: Last Resort,  Prev: Chained Rules,  Up: Implicit Rules
  6584.  
  6585. 10.5 Defining and Redefining Pattern Rules
  6586. ==========================================
  6587.  
  6588. You define an implicit rule by writing a "pattern rule".  A pattern
  6589. rule looks like an ordinary rule, except that its target contains the
  6590. character `%' (exactly one of them).  The target is considered a
  6591. pattern for matching file names; the `%' can match any nonempty
  6592. substring, while other characters match only themselves.  The
  6593. prerequisites likewise use `%' to show how their names relate to the
  6594. target name.
  6595.  
  6596.    Thus, a pattern rule `%.o : %.c' says how to make any file `STEM.o'
  6597. from another file `STEM.c'.
  6598.  
  6599.    Note that expansion using `%' in pattern rules occurs *after* any
  6600. variable or function expansions, which take place when the makefile is
  6601. read.  *Note How to Use Variables: Using Variables, and *Note Functions
  6602. for Transforming Text: Functions.
  6603.  
  6604. * Menu:
  6605.  
  6606. * Pattern Intro::               An introduction to pattern rules.
  6607. * Pattern Examples::            Examples of pattern rules.
  6608. * Automatic::                   How to use automatic variables in the
  6609.                                   commands of implicit rules.
  6610. * Pattern Match::               How patterns match.
  6611. * Match-Anything Rules::        Precautions you should take prior to
  6612.                                   defining rules that can match any
  6613.                                   target file whatever.
  6614. * Canceling Rules::             How to override or cancel built-in rules.
  6615.  
  6616. 
  6617. File: make,  Node: Pattern Intro,  Next: Pattern Examples,  Prev: Pattern Rules,  Up: Pattern Rules
  6618.  
  6619. 10.5.1 Introduction to Pattern Rules
  6620. ------------------------------------
  6621.  
  6622. A pattern rule contains the character `%' (exactly one of them) in the
  6623. target; otherwise, it looks exactly like an ordinary rule.  The target
  6624. is a pattern for matching file names; the `%' matches any nonempty
  6625. substring, while other characters match only themselves.  
  6626.  
  6627.    For example, `%.c' as a pattern matches any file name that ends in
  6628. `.c'.  `s.%.c' as a pattern matches any file name that starts with
  6629. `s.', ends in `.c' and is at least five characters long.  (There must
  6630. be at least one character to match the `%'.)  The substring that the
  6631. `%' matches is called the "stem".
  6632.  
  6633.    `%' in a prerequisite of a pattern rule stands for the same stem
  6634. that was matched by the `%' in the target.  In order for the pattern
  6635. rule to apply, its target pattern must match the file name under
  6636. consideration, and its prerequisite patterns must name files that exist
  6637. or can be made.  These files become prerequisites of the target.  
  6638.  
  6639.    Thus, a rule of the form
  6640.  
  6641.      %.o : %.c ; COMMAND...
  6642.  
  6643. specifies how to make a file `N.o', with another file `N.c' as its
  6644. prerequisite, provided that `N.c' exists or can be made.
  6645.  
  6646.    There may also be prerequisites that do not use `%'; such a
  6647. prerequisite attaches to every file made by this pattern rule.  These
  6648. unvarying prerequisites are useful occasionally.
  6649.  
  6650.    A pattern rule need not have any prerequisites that contain `%', or
  6651. in fact any prerequisites at all.  Such a rule is effectively a general
  6652. wildcard.  It provides a way to make any file that matches the target
  6653. pattern.  *Note Last Resort::.
  6654.  
  6655.    Pattern rules may have more than one target.  Unlike normal rules,
  6656. this does not act as many different rules with the same prerequisites
  6657. and commands.  If a pattern rule has multiple targets, `make' knows that
  6658. the rule's commands are responsible for making all of the targets.  The
  6659. commands are executed only once to make all the targets.  When searching
  6660. for a pattern rule to match a target, the target patterns of a rule
  6661. other than the one that matches the target in need of a rule are
  6662. incidental: `make' worries only about giving commands and prerequisites
  6663. to the file presently in question.  However, when this file's commands
  6664. are run, the other targets are marked as having been updated themselves.  
  6665.  
  6666.    The order in which pattern rules appear in the makefile is important
  6667. since this is the order in which they are considered.  Of equally
  6668. applicable rules, only the first one found is used.  The rules you
  6669. write take precedence over those that are built in.  Note however, that
  6670. a rule whose prerequisites actually exist or are mentioned always takes
  6671. priority over a rule with prerequisites that must be made by chaining
  6672. other implicit rules.  
  6673.  
  6674. 
  6675. File: make,  Node: Pattern Examples,  Next: Automatic,  Prev: Pattern Intro,  Up: Pattern Rules
  6676.  
  6677. 10.5.2 Pattern Rule Examples
  6678. ----------------------------
  6679.  
  6680. Here are some examples of pattern rules actually predefined in `make'.
  6681. First, the rule that compiles `.c' files into `.o' files:
  6682.  
  6683.      %.o : %.c
  6684.              $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
  6685.  
  6686. defines a rule that can make any file `X.o' from `X.c'.  The command
  6687. uses the automatic variables `$@' and `$<' to substitute the names of
  6688. the target file and the source file in each case where the rule applies
  6689. (*note Automatic Variables: Automatic.).
  6690.  
  6691.    Here is a second built-in rule:
  6692.  
  6693.      % :: RCS/%,v
  6694.              $(CO) $(COFLAGS) $<
  6695.  
  6696. defines a rule that can make any file `X' whatsoever from a
  6697. corresponding file `X,v' in the subdirectory `RCS'.  Since the target
  6698. is `%', this rule will apply to any file whatever, provided the
  6699. appropriate prerequisite file exists.  The double colon makes the rule
  6700. "terminal", which means that its prerequisite may not be an intermediate
  6701. file (*note Match-Anything Pattern Rules: Match-Anything Rules.).
  6702.  
  6703.    This pattern rule has two targets:
  6704.  
  6705.      %.tab.c %.tab.h: %.y
  6706.              bison -d $<
  6707.  
  6708. This tells `make' that the command `bison -d X.y' will make both
  6709. `X.tab.c' and `X.tab.h'.  If the file `foo' depends on the files
  6710. `parse.tab.o' and `scan.o' and the file `scan.o' depends on the file
  6711. `parse.tab.h', when `parse.y' is changed, the command `bison -d parse.y'
  6712. will be executed only once, and the prerequisites of both `parse.tab.o'
  6713. and `scan.o' will be satisfied.  (Presumably the file `parse.tab.o'
  6714. will be recompiled from `parse.tab.c' and the file `scan.o' from
  6715. `scan.c', while `foo' is linked from `parse.tab.o', `scan.o', and its
  6716. other prerequisites, and it will execute happily ever after.)
  6717.  
  6718. 
  6719. File: make,  Node: Automatic,  Next: Pattern Match,  Prev: Pattern Examples,  Up: Pattern Rules
  6720.  
  6721. 10.5.3 Automatic Variables
  6722. --------------------------
  6723.  
  6724. Suppose you are writing a pattern rule to compile a `.c' file into a
  6725. `.o' file: how do you write the `cc' command so that it operates on the
  6726. right source file name?  You cannot write the name in the command,
  6727. because the name is different each time the implicit rule is applied.
  6728.  
  6729.    What you do is use a special feature of `make', the "automatic
  6730. variables".  These variables have values computed afresh for each rule
  6731. that is executed, based on the target and prerequisites of the rule.
  6732. In this example, you would use `$@' for the object file name and `$<'
  6733. for the source file name.
  6734.  
  6735.    Here is a table of automatic variables:
  6736.  
  6737. `$@'
  6738.      The file name of the target of the rule.  If the target is an
  6739.      archive member, then `$@' is the name of the archive file.  In a
  6740.      pattern rule that has multiple targets (*note Introduction to
  6741.      Pattern Rules: Pattern Intro.), `$@' is the name of whichever
  6742.      target caused the rule's commands to be run.
  6743.  
  6744. `$%'
  6745.      The target member name, when the target is an archive member.
  6746.      *Note Archives::.  For example, if the target is `foo.a(bar.o)'
  6747.      then `$%' is `bar.o' and `$@' is `foo.a'.  `$%' is empty when the
  6748.      target is not an archive member.
  6749.  
  6750. `$<'
  6751.      The name of the first prerequisite.  If the target got its
  6752.      commands from an implicit rule, this will be the first
  6753.      prerequisite added by the implicit rule (*note Implicit Rules::).
  6754.  
  6755. `$?'
  6756.      The names of all the prerequisites that are newer than the target,
  6757.      with spaces between them.  For prerequisites which are archive
  6758.      members, only the member named is used (*note Archives::).  
  6759.  
  6760. `$^'
  6761.      The names of all the prerequisites, with spaces between them.  For
  6762.      prerequisites which are archive members, only the member named is
  6763.      used (*note Archives::).  A target has only one prerequisite on
  6764.      each other file it depends on, no matter how many times each file
  6765.      is listed as a prerequisite.  So if you list a prerequisite more
  6766.      than once for a target, the value of `$^' contains just one copy
  6767.      of the name.  
  6768.  
  6769. `$+'
  6770.      This is like `$^', but prerequisites listed more than once are
  6771.      duplicated in the order they were listed in the makefile.  This is
  6772.      primarily useful for use in linking commands where it is
  6773.      meaningful to repeat library file names in a particular order.
  6774.  
  6775. `$*'
  6776.      The stem with which an implicit rule matches (*note How Patterns
  6777.      Match: Pattern Match.).  If the target is `dir/a.foo.b' and the
  6778.      target pattern is `a.%.b' then the stem is `dir/foo'.  The stem is
  6779.      useful for constructing names of related files.  
  6780.  
  6781.      In a static pattern rule, the stem is part of the file name that
  6782.      matched the `%' in the target pattern.
  6783.  
  6784.      In an explicit rule, there is no stem; so `$*' cannot be determined
  6785.      in that way.  Instead, if the target name ends with a recognized
  6786.      suffix (*note Old-Fashioned Suffix Rules: Suffix Rules.), `$*' is
  6787.      set to the target name minus the suffix.  For example, if the
  6788.      target name is `foo.c', then `$*' is set to `foo', since `.c' is a
  6789.      suffix.  GNU `make' does this bizarre thing only for compatibility
  6790.      with other implementations of `make'.  You should generally avoid
  6791.      using `$*' except in implicit rules or static pattern rules.
  6792.  
  6793.      If the target name in an explicit rule does not end with a
  6794.      recognized suffix, `$*' is set to the empty string for that rule.
  6795.  
  6796.    `$?' is useful even in explicit rules when you wish to operate on
  6797. only the prerequisites that have changed.  For example, suppose that an
  6798. archive named `lib' is supposed to contain copies of several object
  6799. files.  This rule copies just the changed object files into the archive:
  6800.  
  6801.      lib: foo.o bar.o lose.o win.o
  6802.              ar r lib $?
  6803.  
  6804.    Of the variables listed above, four have values that are single file
  6805. names, and three have values that are lists of file names.  These seven
  6806. have variants that get just the file's directory name or just the file
  6807. name within the directory.  The variant variables' names are formed by
  6808. appending `D' or `F', respectively.  These variants are semi-obsolete
  6809. in GNU `make' since the functions `dir' and `notdir' can be used to get
  6810. a similar effect (*note Functions for File Names: File Name
  6811. Functions.).  Note, however, that the `D' variants all omit the
  6812. trailing slash which always appears in the output of the `dir'
  6813. function.  Here is a table of the variants:
  6814.  
  6815. `$(@D)'
  6816.      The directory part of the file name of the target, with the
  6817.      trailing slash removed.  If the value of `$@' is `dir/foo.o' then
  6818.      `$(@D)' is `dir'.  This value is `.' if `$@' does not contain a
  6819.      slash.
  6820.  
  6821. `$(@F)'
  6822.      The file-within-directory part of the file name of the target.  If
  6823.      the value of `$@' is `dir/foo.o' then `$(@F)' is `foo.o'.  `$(@F)'
  6824.      is equivalent to `$(notdir $@)'.
  6825.  
  6826. `$(*D)'
  6827. `$(*F)'
  6828.      The directory part and the file-within-directory part of the stem;
  6829.      `dir' and `foo' in this example.
  6830.  
  6831. `$(%D)'
  6832. `$(%F)'
  6833.      The directory part and the file-within-directory part of the target
  6834.      archive member name.  This makes sense only for archive member
  6835.      targets of the form `ARCHIVE(MEMBER)' and is useful only when
  6836.      MEMBER may contain a directory name.  (*Note Archive Members as
  6837.      Targets: Archive Members.)
  6838.  
  6839. `$(<D)'
  6840. `$(<F)'
  6841.      The directory part and the file-within-directory part of the first
  6842.      prerequisite.
  6843.  
  6844. `$(^D)'
  6845. `$(^F)'
  6846.      Lists of the directory parts and the file-within-directory parts
  6847.      of all prerequisites.
  6848.  
  6849. `$(+D)'
  6850. `$(+F)'
  6851.      Lists of the directory parts and the file-within-directory parts
  6852.      of all prerequisites, including multiple instances of duplicated
  6853.      prerequisites.
  6854.  
  6855. `$(?D)'
  6856. `$(?F)'
  6857.      Lists of the directory parts and the file-within-directory parts of
  6858.      all prerequisites that are newer than the target.
  6859.  
  6860.    Note that we use a special stylistic convention when we talk about
  6861. these automatic variables; we write "the value of `$<'", rather than
  6862. "the variable `<'" as we would write for ordinary variables such as
  6863. `objects' and `CFLAGS'.  We think this convention looks more natural in
  6864. this special case.  Please do not assume it has a deep significance;
  6865. `$<' refers to the variable named `<' just as `$(CFLAGS)' refers to the
  6866. variable named `CFLAGS'.  You could just as well use `$(<)' in place of
  6867. `$<'.
  6868.  
  6869.    GNU `make' provides support for the SysV `make' feature that allows
  6870. special variable references `$$@', `$$(@D)', and `$$(@F)' (note the
  6871. required double-"$"!) to appear with the _prerequisites list_ (normal
  6872. automatic variables are available only within a command script).  When
  6873. appearing in a prerequisites list, these variables are expanded to the
  6874. name of the target, the directory component of the target, and the file
  6875. component of the target, respectively.
  6876.  
  6877.    Note that these variables are available only within explicit and
  6878. static pattern (*note Static Pattern Rules: Static Pattern.) rules;
  6879. they have no special significance within implicit (suffix or pattern)
  6880. rules.  Also note that while SysV `make' actually expands its entire
  6881. prerequisite list _twice_, GNU `make' does not behave this way: instead
  6882. it simply expands these special variables without re-expanding any
  6883. other part of the prerequisites list.
  6884.  
  6885.    This somewhat bizarre feature is included only to provide some
  6886. compatibility with SysV makefiles.  In a native GNU `make' file there
  6887. are other ways to accomplish the same results.  This feature is
  6888. disabled if the special pseudo target `.POSIX' is defined.
  6889.  
  6890. 
  6891. File: make,  Node: Pattern Match,  Next: Match-Anything Rules,  Prev: Automatic,  Up: Pattern Rules
  6892.  
  6893. 10.5.4 How Patterns Match
  6894. -------------------------
  6895.  
  6896. A target pattern is composed of a `%' between a prefix and a suffix,
  6897. either or both of which may be empty.  The pattern matches a file name
  6898. only if the file name starts with the prefix and ends with the suffix,
  6899. without overlap.  The text between the prefix and the suffix is called
  6900. the "stem".  Thus, when the pattern `%.o' matches the file name
  6901. `test.o', the stem is `test'.  The pattern rule prerequisites are
  6902. turned into actual file names by substituting the stem for the character
  6903. `%'.  Thus, if in the same example one of the prerequisites is written
  6904. as `%.c', it expands to `test.c'.
  6905.  
  6906.    When the target pattern does not contain a slash (and it usually does
  6907. not), directory names in the file names are removed from the file name
  6908. before it is compared with the target prefix and suffix.  After the
  6909. comparison of the file name to the target pattern, the directory names,
  6910. along with the slash that ends them, are added on to the prerequisite
  6911. file names generated from the pattern rule's prerequisite patterns and
  6912. the file name. The directories are ignored only for the purpose of
  6913. finding an implicit rule to use, not in the application of that rule.
  6914. Thus, `e%t' matches the file name `src/eat', with `src/a' as the stem.
  6915. When prerequisites are turned into file names, the directories from the
  6916. stem are added at the front, while the rest of the stem is substituted
  6917. for the `%'.  The stem `src/a' with a prerequisite pattern `c%r' gives
  6918. the file name `src/car'.
  6919.  
  6920. 
  6921. File: make,  Node: Match-Anything Rules,  Next: Canceling Rules,  Prev: Pattern Match,  Up: Pattern Rules
  6922.  
  6923. 10.5.5 Match-Anything Pattern Rules
  6924. -----------------------------------
  6925.  
  6926. When a pattern rule's target is just `%', it matches any file name
  6927. whatever.  We call these rules "match-anything" rules.  They are very
  6928. useful, but it can take a lot of time for `make' to think about them,
  6929. because it must consider every such rule for each file name listed
  6930. either as a target or as a prerequisite.
  6931.  
  6932.    Suppose the makefile mentions `foo.c'.  For this target, `make'
  6933. would have to consider making it by linking an object file `foo.c.o',
  6934. or by C compilation-and-linking in one step from `foo.c.c', or by
  6935. Pascal compilation-and-linking from `foo.c.p', and many other
  6936. possibilities.
  6937.  
  6938.    We know these possibilities are ridiculous since `foo.c' is a C
  6939. source file, not an executable.  If `make' did consider these
  6940. possibilities, it would ultimately reject them, because files such as
  6941. `foo.c.o' and `foo.c.p' would not exist.  But these possibilities are so
  6942. numerous that `make' would run very slowly if it had to consider them.
  6943.  
  6944.    To gain speed, we have put various constraints on the way `make'
  6945. considers match-anything rules.  There are two different constraints
  6946. that can be applied, and each time you define a match-anything rule you
  6947. must choose one or the other for that rule.
  6948.  
  6949.    One choice is to mark the match-anything rule as "terminal" by
  6950. defining it with a double colon.  When a rule is terminal, it does not
  6951. apply unless its prerequisites actually exist.  Prerequisites that
  6952. could be made with other implicit rules are not good enough.  In other
  6953. words, no further chaining is allowed beyond a terminal rule.
  6954.  
  6955.    For example, the built-in implicit rules for extracting sources from
  6956. RCS and SCCS files are terminal; as a result, if the file `foo.c,v' does
  6957. not exist, `make' will not even consider trying to make it as an
  6958. intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'.  RCS
  6959. and SCCS files are generally ultimate source files, which should not be
  6960. remade from any other files; therefore, `make' can save time by not
  6961. looking for ways to remake them.
  6962.  
  6963.    If you do not mark the match-anything rule as terminal, then it is
  6964. nonterminal.  A nonterminal match-anything rule cannot apply to a file
  6965. name that indicates a specific type of data.  A file name indicates a
  6966. specific type of data if some non-match-anything implicit rule target
  6967. matches it.
  6968.  
  6969.    For example, the file name `foo.c' matches the target for the pattern
  6970. rule `%.c : %.y' (the rule to run Yacc).  Regardless of whether this
  6971. rule is actually applicable (which happens only if there is a file
  6972. `foo.y'), the fact that its target matches is enough to prevent
  6973. consideration of any nonterminal match-anything rules for the file
  6974. `foo.c'.  Thus, `make' will not even consider trying to make `foo.c' as
  6975. an executable file from `foo.c.o', `foo.c.c', `foo.c.p', etc.
  6976.  
  6977.    The motivation for this constraint is that nonterminal match-anything
  6978. rules are used for making files containing specific types of data (such
  6979. as executable files) and a file name with a recognized suffix indicates
  6980. some other specific type of data (such as a C source file).
  6981.  
  6982.    Special built-in dummy pattern rules are provided solely to recognize
  6983. certain file names so that nonterminal match-anything rules will not be
  6984. considered.  These dummy rules have no prerequisites and no commands,
  6985. and they are ignored for all other purposes.  For example, the built-in
  6986. implicit rule
  6987.  
  6988.      %.p :
  6989.  
  6990. exists to make sure that Pascal source files such as `foo.p' match a
  6991. specific target pattern and thereby prevent time from being wasted
  6992. looking for `foo.p.o' or `foo.p.c'.
  6993.  
  6994.    Dummy pattern rules such as the one for `%.p' are made for every
  6995. suffix listed as valid for use in suffix rules (*note Old-Fashioned
  6996. Suffix Rules: Suffix Rules.).
  6997.  
  6998. 
  6999. File: make,  Node: Canceling Rules,  Prev: Match-Anything Rules,  Up: Pattern Rules
  7000.  
  7001. 10.5.6 Canceling Implicit Rules
  7002. -------------------------------
  7003.  
  7004. You can override a built-in implicit rule (or one you have defined
  7005. yourself) by defining a new pattern rule with the same target and
  7006. prerequisites, but different commands.  When the new rule is defined,
  7007. the built-in one is replaced.  The new rule's position in the sequence
  7008. of implicit rules is determined by where you write the new rule.
  7009.  
  7010.    You can cancel a built-in implicit rule by defining a pattern rule
  7011. with the same target and prerequisites, but no commands.  For example,
  7012. the following would cancel the rule that runs the assembler:
  7013.  
  7014.      %.o : %.s
  7015.  
  7016. 
  7017. File: make,  Node: Last Resort,  Next: Suffix Rules,  Prev: Pattern Rules,  Up: Implicit Rules
  7018.  
  7019. 10.6 Defining Last-Resort Default Rules
  7020. =======================================
  7021.  
  7022. You can define a last-resort implicit rule by writing a terminal
  7023. match-anything pattern rule with no prerequisites (*note Match-Anything
  7024. Rules::).  This is just like any other pattern rule; the only thing
  7025. special about it is that it will match any target.  So such a rule's
  7026. commands are used for all targets and prerequisites that have no
  7027. commands of their own and for which no other implicit rule applies.
  7028.  
  7029.    For example, when testing a makefile, you might not care if the
  7030. source files contain real data, only that they exist.  Then you might
  7031. do this:
  7032.  
  7033.      %::
  7034.              touch $@
  7035.  
  7036. to cause all the source files needed (as prerequisites) to be created
  7037. automatically.
  7038.  
  7039.    You can instead define commands to be used for targets for which
  7040. there are no rules at all, even ones which don't specify commands.  You
  7041. do this by writing a rule for the target `.DEFAULT'.  Such a rule's
  7042. commands are used for all prerequisites which do not appear as targets
  7043. in any explicit rule, and for which no implicit rule applies.
  7044. Naturally, there is no `.DEFAULT' rule unless you write one.
  7045.  
  7046.    If you use `.DEFAULT' with no commands or prerequisites:
  7047.  
  7048.      .DEFAULT:
  7049.  
  7050. the commands previously stored for `.DEFAULT' are cleared.  Then `make'
  7051. acts as if you had never defined `.DEFAULT' at all.
  7052.  
  7053.    If you do not want a target to get the commands from a match-anything
  7054. pattern rule or `.DEFAULT', but you also do not want any commands to be
  7055. run for the target, you can give it empty commands (*note Defining
  7056. Empty Commands: Empty Commands.).
  7057.  
  7058.    You can use a last-resort rule to override part of another makefile.
  7059. *Note Overriding Part of Another Makefile: Overriding Makefiles.
  7060.  
  7061. 
  7062. File: make,  Node: Suffix Rules,  Next: Implicit Rule Search,  Prev: Last Resort,  Up: Implicit Rules
  7063.  
  7064. 10.7 Old-Fashioned Suffix Rules
  7065. ===============================
  7066.  
  7067. "Suffix rules" are the old-fashioned way of defining implicit rules for
  7068. `make'.  Suffix rules are obsolete because pattern rules are more
  7069. general and clearer.  They are supported in GNU `make' for
  7070. compatibility with old makefiles.  They come in two kinds:
  7071. "double-suffix" and "single-suffix".
  7072.  
  7073.    A double-suffix rule is defined by a pair of suffixes: the target
  7074. suffix and the source suffix.  It matches any file whose name ends with
  7075. the target suffix.  The corresponding implicit prerequisite is made by
  7076. replacing the target suffix with the source suffix in the file name.  A
  7077. two-suffix rule whose target and source suffixes are `.o' and `.c' is
  7078. equivalent to the pattern rule `%.o : %.c'.
  7079.  
  7080.    A single-suffix rule is defined by a single suffix, which is the
  7081. source suffix.  It matches any file name, and the corresponding implicit
  7082. prerequisite name is made by appending the source suffix.  A
  7083. single-suffix rule whose source suffix is `.c' is equivalent to the
  7084. pattern rule `% : %.c'.
  7085.  
  7086.    Suffix rule definitions are recognized by comparing each rule's
  7087. target against a defined list of known suffixes.  When `make' sees a
  7088. rule whose target is a known suffix, this rule is considered a
  7089. single-suffix rule.  When `make' sees a rule whose target is two known
  7090. suffixes concatenated, this rule is taken as a double-suffix rule.
  7091.  
  7092.    For example, `.c' and `.o' are both on the default list of known
  7093. suffixes.  Therefore, if you define a rule whose target is `.c.o',
  7094. `make' takes it to be a double-suffix rule with source suffix `.c' and
  7095. target suffix `.o'.  Here is the old-fashioned way to define the rule
  7096. for compiling a C source file:
  7097.  
  7098.      .c.o:
  7099.              $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
  7100.  
  7101.    Suffix rules cannot have any prerequisites of their own.  If they
  7102. have any, they are treated as normal files with funny names, not as
  7103. suffix rules.  Thus, the rule:
  7104.  
  7105.      .c.o: foo.h
  7106.              $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
  7107.  
  7108. tells how to make the file `.c.o' from the prerequisite file `foo.h',
  7109. and is not at all like the pattern rule:
  7110.  
  7111.      %.o: %.c foo.h
  7112.              $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
  7113.  
  7114. which tells how to make `.o' files from `.c' files, and makes all `.o'
  7115. files using this pattern rule also depend on `foo.h'.
  7116.  
  7117.    Suffix rules with no commands are also meaningless.  They do not
  7118. remove previous rules as do pattern rules with no commands (*note
  7119. Canceling Implicit Rules: Canceling Rules.).  They simply enter the
  7120. suffix or pair of suffixes concatenated as a target in the data base.
  7121.  
  7122.    The known suffixes are simply the names of the prerequisites of the
  7123. special target `.SUFFIXES'.  You can add your own suffixes by writing a
  7124. rule for `.SUFFIXES' that adds more prerequisites, as in:
  7125.  
  7126.      .SUFFIXES: .hack .win
  7127.  
  7128. which adds `.hack' and `.win' to the end of the list of suffixes.
  7129.  
  7130.    If you wish to eliminate the default known suffixes instead of just
  7131. adding to them, write a rule for `.SUFFIXES' with no prerequisites.  By
  7132. special dispensation, this eliminates all existing prerequisites of
  7133. `.SUFFIXES'.  You can then write another rule to add the suffixes you
  7134. want.  For example,
  7135.  
  7136.      .SUFFIXES:            # Delete the default suffixes
  7137.      .SUFFIXES: .c .o .h   # Define our suffix list
  7138.  
  7139.    The `-r' or `--no-builtin-rules' flag causes the default list of
  7140. suffixes to be empty.
  7141.  
  7142.    The variable `SUFFIXES' is defined to the default list of suffixes
  7143. before `make' reads any makefiles.  You can change the list of suffixes
  7144. with a rule for the special target `.SUFFIXES', but that does not alter
  7145. this variable.
  7146.  
  7147. 
  7148. File: make,  Node: Implicit Rule Search,  Prev: Suffix Rules,  Up: Implicit Rules
  7149.  
  7150. 10.8 Implicit Rule Search Algorithm
  7151. ===================================
  7152.  
  7153. Here is the procedure `make' uses for searching for an implicit rule
  7154. for a target T.  This procedure is followed for each double-colon rule
  7155. with no commands, for each target of ordinary rules none of which have
  7156. commands, and for each prerequisite that is not the target of any rule.
  7157. It is also followed recursively for prerequisites that come from
  7158. implicit rules, in the search for a chain of rules.
  7159.  
  7160.    Suffix rules are not mentioned in this algorithm because suffix
  7161. rules are converted to equivalent pattern rules once the makefiles have
  7162. been read in.
  7163.  
  7164.    For an archive member target of the form `ARCHIVE(MEMBER)', the
  7165. following algorithm is run twice, first using the entire target name T,
  7166. and second using `(MEMBER)' as the target T if the first run found no
  7167. rule.
  7168.  
  7169.   1. Split T into a directory part, called D, and the rest, called N.
  7170.      For example, if T is `src/foo.o', then D is `src/' and N is
  7171.      `foo.o'.
  7172.  
  7173.   2. Make a list of all the pattern rules one of whose targets matches
  7174.      T or N.  If the target pattern contains a slash, it is matched
  7175.      against T; otherwise, against N.
  7176.  
  7177.   3. If any rule in that list is _not_ a match-anything rule, then
  7178.      remove all nonterminal match-anything rules from the list.
  7179.  
  7180.   4. Remove from the list all rules with no commands.
  7181.  
  7182.   5. For each pattern rule in the list:
  7183.  
  7184.        a. Find the stem S, which is the nonempty part of T or N matched
  7185.           by the `%' in the target pattern.
  7186.  
  7187.        b. Compute the prerequisite names by substituting S for `%'; if
  7188.           the target pattern does not contain a slash, append D to the
  7189.           front of each prerequisite name.
  7190.  
  7191.        c. Test whether all the prerequisites exist or ought to exist.
  7192.           (If a file name is mentioned in the makefile as a target or
  7193.           as an explicit prerequisite, then we say it ought to exist.)
  7194.  
  7195.           If all prerequisites exist or ought to exist, or there are no
  7196.           prerequisites, then this rule applies.
  7197.  
  7198.   6. If no pattern rule has been found so far, try harder.  For each
  7199.      pattern rule in the list:
  7200.  
  7201.        a. If the rule is terminal, ignore it and go on to the next rule.
  7202.  
  7203.        b. Compute the prerequisite names as before.
  7204.  
  7205.        c. Test whether all the prerequisites exist or ought to exist.
  7206.  
  7207.        d. For each prerequisite that does not exist, follow this
  7208.           algorithm recursively to see if the prerequisite can be made
  7209.           by an implicit rule.
  7210.  
  7211.        e. If all prerequisites exist, ought to exist, or can be made by
  7212.           implicit rules, then this rule applies.
  7213.  
  7214.   7. If no implicit rule applies, the rule for `.DEFAULT', if any,
  7215.      applies.  In that case, give T the same commands that `.DEFAULT'
  7216.      has.  Otherwise, there are no commands for T.
  7217.  
  7218.    Once a rule that applies has been found, for each target pattern of
  7219. the rule other than the one that matched T or N, the `%' in the pattern
  7220. is replaced with S and the resultant file name is stored until the
  7221. commands to remake the target file T are executed.  After these
  7222. commands are executed, each of these stored file names are entered into
  7223. the data base and marked as having been updated and having the same
  7224. update status as the file T.
  7225.  
  7226.    When the commands of a pattern rule are executed for T, the automatic
  7227. variables are set corresponding to the target and prerequisites.  *Note
  7228. Automatic Variables: Automatic.
  7229.  
  7230. 
  7231. File: make,  Node: Archives,  Next: Features,  Prev: Implicit Rules,  Up: Top
  7232.  
  7233. 11 Using `make' to Update Archive Files
  7234. ***************************************
  7235.  
  7236. "Archive files" are files containing named subfiles called "members";
  7237. they are maintained with the program `ar' and their main use is as
  7238. subroutine libraries for linking.
  7239.  
  7240. * Menu:
  7241.  
  7242. * Archive Members::             Archive members as targets.
  7243. * Archive Update::              The implicit rule for archive member targets.
  7244. * Archive Pitfalls::            Dangers to watch out for when using archives.
  7245. * Archive Suffix Rules::        You can write a special kind of suffix rule
  7246.                                   for updating archives.
  7247.  
  7248. 
  7249. File: make,  Node: Archive Members,  Next: Archive Update,  Prev: Archives,  Up: Archives
  7250.  
  7251. 11.1 Archive Members as Targets
  7252. ===============================
  7253.  
  7254. An individual member of an archive file can be used as a target or
  7255. prerequisite in `make'.  You specify the member named MEMBER in archive
  7256. file ARCHIVE as follows:
  7257.  
  7258.      ARCHIVE(MEMBER)
  7259.  
  7260. This construct is available only in targets and prerequisites, not in
  7261. commands!  Most programs that you might use in commands do not support
  7262. this syntax and cannot act directly on archive members.  Only `ar' and
  7263. other programs specifically designed to operate on archives can do so.
  7264. Therefore, valid commands to update an archive member target probably
  7265. must use `ar'.  For example, this rule says to create a member `hack.o'
  7266. in archive `foolib' by copying the file `hack.o':
  7267.  
  7268.      foolib(hack.o) : hack.o
  7269.              ar cr foolib hack.o
  7270.  
  7271.    In fact, nearly all archive member targets are updated in just this
  7272. way and there is an implicit rule to do it for you.  *Note_* The `c'
  7273. flag to `ar' is required if the archive file does not already exist.
  7274.  
  7275.    To specify several members in the same archive, you can write all the
  7276. member names together between the parentheses.  For example:
  7277.  
  7278.      foolib(hack.o kludge.o)
  7279.  
  7280. is equivalent to:
  7281.  
  7282.      foolib(hack.o) foolib(kludge.o)
  7283.  
  7284.    You can also use shell-style wildcards in an archive member
  7285. reference.  *Note Using Wildcard Characters in File Names: Wildcards.
  7286. For example, `foolib(*.o)' expands to all existing members of the
  7287. `foolib' archive whose names end in `.o'; perhaps `foolib(hack.o)
  7288. foolib(kludge.o)'.
  7289.  
  7290. 
  7291. File: make,  Node: Archive Update,  Next: Archive Pitfalls,  Prev: Archive Members,  Up: Archives
  7292.  
  7293. 11.2 Implicit Rule for Archive Member Targets
  7294. =============================================
  7295.  
  7296. Recall that a target that looks like `A(M)' stands for the member named
  7297. M in the archive file A.
  7298.  
  7299.    When `make' looks for an implicit rule for such a target, as a
  7300. special feature it considers implicit rules that match `(M)', as well as
  7301. those that match the actual target `A(M)'.
  7302.  
  7303.    This causes one special rule whose target is `(%)' to match.  This
  7304. rule updates the target `A(M)' by copying the file M into the archive.
  7305. For example, it will update the archive member target `foo.a(bar.o)' by
  7306. copying the _file_ `bar.o' into the archive `foo.a' as a _member_ named
  7307. `bar.o'.
  7308.  
  7309.    When this rule is chained with others, the result is very powerful.
  7310. Thus, `make "foo.a(bar.o)"' (the quotes are needed to protect the `('
  7311. and `)' from being interpreted specially by the shell) in the presence
  7312. of a file `bar.c' is enough to cause the following commands to be run,
  7313. even without a makefile:
  7314.  
  7315.      cc -c bar.c -o bar.o
  7316.      ar r foo.a bar.o
  7317.      rm -f bar.o
  7318.  
  7319. Here `make' has envisioned the file `bar.o' as an intermediate file.
  7320. *Note Chains of Implicit Rules: Chained Rules.
  7321.  
  7322.    Implicit rules such as this one are written using the automatic
  7323. variable `$%'.  *Note Automatic Variables: Automatic.
  7324.  
  7325.    An archive member name in an archive cannot contain a directory
  7326. name, but it may be useful in a makefile to pretend that it does.  If
  7327. you write an archive member target `foo.a(dir/file.o)', `make' will
  7328. perform automatic updating with this command:
  7329.  
  7330.      ar r foo.a dir/file.o
  7331.  
  7332. which has the effect of copying the file `dir/file.o' into a member
  7333. named `file.o'.  In connection with such usage, the automatic variables
  7334. `%D' and `%F' may be useful.
  7335.  
  7336. * Menu:
  7337.  
  7338. * Archive Symbols::             How to update archive symbol directories.
  7339.  
  7340. 
  7341. File: make,  Node: Archive Symbols,  Prev: Archive Update,  Up: Archive Update
  7342.  
  7343. 11.2.1 Updating Archive Symbol Directories
  7344. ------------------------------------------
  7345.  
  7346. An archive file that is used as a library usually contains a special
  7347. member named `__.SYMDEF' that contains a directory of the external
  7348. symbol names defined by all the other members.  After you update any
  7349. other members, you need to update `__.SYMDEF' so that it will summarize
  7350. the other members properly.  This is done by running the `ranlib'
  7351. program:
  7352.  
  7353.      ranlib ARCHIVEFILE
  7354.  
  7355.    Normally you would put this command in the rule for the archive file,
  7356. and make all the members of the archive file prerequisites of that rule.
  7357. For example,
  7358.  
  7359.      libfoo.a: libfoo.a(x.o) libfoo.a(y.o) ...
  7360.              ranlib libfoo.a
  7361.  
  7362. The effect of this is to update archive members `x.o', `y.o', etc., and
  7363. then update the symbol directory member `__.SYMDEF' by running
  7364. `ranlib'.  The rules for updating the members are not shown here; most
  7365. likely you can omit them and use the implicit rule which copies files
  7366. into the archive, as described in the preceding section.
  7367.  
  7368.    This is not necessary when using the GNU `ar' program, which updates
  7369. the `__.SYMDEF' member automatically.
  7370.  
  7371. 
  7372. File: make,  Node: Archive Pitfalls,  Next: Archive Suffix Rules,  Prev: Archive Update,  Up: Archives
  7373.  
  7374. 11.3 Dangers When Using Archives
  7375. ================================
  7376.  
  7377. It is important to be careful when using parallel execution (the `-j'
  7378. switch; *note Parallel Execution: Parallel.) and archives.  If multiple
  7379. `ar' commands run at the same time on the same archive file, they will
  7380. not know about each other and can corrupt the file.
  7381.  
  7382.    Possibly a future version of `make' will provide a mechanism to
  7383. circumvent this problem by serializing all commands that operate on the
  7384. same archive file.  But for the time being, you must either write your
  7385. makefiles to avoid this problem in some other way, or not use `-j'.
  7386.  
  7387. 
  7388. File: make,  Node: Archive Suffix Rules,  Prev: Archive Pitfalls,  Up: Archives
  7389.  
  7390. 11.4 Suffix Rules for Archive Files
  7391. ===================================
  7392.  
  7393. You can write a special kind of suffix rule for dealing with archive
  7394. files.  *Note Suffix Rules::, for a full explanation of suffix rules.
  7395. Archive suffix rules are obsolete in GNU `make', because pattern rules
  7396. for archives are a more general mechanism (*note Archive Update::).
  7397. But they are retained for compatibility with other `make's.
  7398.  
  7399.    To write a suffix rule for archives, you simply write a suffix rule
  7400. using the target suffix `.a' (the usual suffix for archive files).  For
  7401. example, here is the old-fashioned suffix rule to update a library
  7402. archive from C source files:
  7403.  
  7404.      .c.a:
  7405.              $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
  7406.              $(AR) r $@ $*.o
  7407.              $(RM) $*.o
  7408.  
  7409. This works just as if you had written the pattern rule:
  7410.  
  7411.      (%.o): %.c
  7412.              $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
  7413.              $(AR) r $@ $*.o
  7414.              $(RM) $*.o
  7415.  
  7416.    In fact, this is just what `make' does when it sees a suffix rule
  7417. with `.a' as the target suffix.  Any double-suffix rule `.X.a' is
  7418. converted to a pattern rule with the target pattern `(%.o)' and a
  7419. prerequisite pattern of `%.X'.
  7420.  
  7421.    Since you might want to use `.a' as the suffix for some other kind
  7422. of file, `make' also converts archive suffix rules to pattern rules in
  7423. the normal way (*note Suffix Rules::).  Thus a double-suffix rule
  7424. `.X.a' produces two pattern rules: `(%.o): %.X' and `%.a: %.X'.
  7425.  
  7426. 
  7427. File: make,  Node: Features,  Next: Missing,  Prev: Archives,  Up: Top
  7428.  
  7429. 12 Features of GNU `make'
  7430. *************************
  7431.  
  7432. Here is a summary of the features of GNU `make', for comparison with
  7433. and credit to other versions of `make'.  We consider the features of
  7434. `make' in 4.2 BSD systems as a baseline.  If you are concerned with
  7435. writing portable makefiles, you should not use the features of `make'
  7436. listed here, nor the ones in *Note Missing::.
  7437.  
  7438.    Many features come from the version of `make' in System V.
  7439.  
  7440.    * The `VPATH' variable and its special meaning.  *Note Searching
  7441.      Directories for Prerequisites: Directory Search.  This feature
  7442.      exists in System V `make', but is undocumented.  It is documented
  7443.      in 4.3 BSD `make' (which says it mimics System V's `VPATH'
  7444.      feature).
  7445.  
  7446.    * Included makefiles.  *Note Including Other Makefiles: Include.
  7447.      Allowing multiple files to be included with a single directive is
  7448.      a GNU extension.
  7449.  
  7450.    * Variables are read from and communicated via the environment.
  7451.      *Note Variables from the Environment: Environment.
  7452.  
  7453.    * Options passed through the variable `MAKEFLAGS' to recursive
  7454.      invocations of `make'.  *Note Communicating Options to a
  7455.      Sub-`make': Options/Recursion.
  7456.  
  7457.    * The automatic variable `$%' is set to the member name in an
  7458.      archive reference.  *Note Automatic Variables: Automatic.
  7459.  
  7460.    * The automatic variables `$@', `$*', `$<', `$%', and `$?' have
  7461.      corresponding forms like `$(@F)' and `$(@D)'.  We have generalized
  7462.      this to `$^' as an obvious extension.  *Note Automatic Variables:
  7463.      Automatic.
  7464.  
  7465.    * Substitution variable references.  *Note Basics of Variable
  7466.      References: Reference.
  7467.  
  7468.    * The command-line options `-b' and `-m', accepted and ignored.  In
  7469.      System V `make', these options actually do something.
  7470.  
  7471.    * Execution of recursive commands to run `make' via the variable
  7472.      `MAKE' even if `-n', `-q' or `-t' is specified.  *Note Recursive
  7473.      Use of `make': Recursion.
  7474.  
  7475.    * Support for suffix `.a' in suffix rules.  *Note Archive Suffix
  7476.      Rules::.  This feature is obsolete in GNU `make', because the
  7477.      general feature of rule chaining (*note Chains of Implicit Rules:
  7478.      Chained Rules.) allows one pattern rule for installing members in
  7479.      an archive (*note Archive Update::) to be sufficient.
  7480.  
  7481.    * The arrangement of lines and backslash-newline combinations in
  7482.      commands is retained when the commands are printed, so they appear
  7483.      as they do in the makefile, except for the stripping of initial
  7484.      whitespace.
  7485.  
  7486.    The following features were inspired by various other versions of
  7487. `make'.  In some cases it is unclear exactly which versions inspired
  7488. which others.
  7489.  
  7490.    * Pattern rules using `%'.  This has been implemented in several
  7491.      versions of `make'.  We're not sure who invented it first, but
  7492.      it's been spread around a bit.  *Note Defining and Redefining
  7493.      Pattern Rules: Pattern Rules.
  7494.  
  7495.    * Rule chaining and implicit intermediate files.  This was
  7496.      implemented by Stu Feldman in his version of `make' for AT&T
  7497.      Eighth Edition Research Unix, and later by Andrew Hume of AT&T
  7498.      Bell Labs in his `mk' program (where he terms it "transitive
  7499.      closure").  We do not really know if we got this from either of
  7500.      them or thought it up ourselves at the same time.  *Note Chains of
  7501.      Implicit Rules: Chained Rules.
  7502.  
  7503.    * The automatic variable `$^' containing a list of all prerequisites
  7504.      of the current target.  We did not invent this, but we have no
  7505.      idea who did.  *Note Automatic Variables: Automatic.  The
  7506.      automatic variable `$+' is a simple extension of `$^'.
  7507.  
  7508.    * The "what if" flag (`-W' in GNU `make') was (as far as we know)
  7509.      invented by Andrew Hume in `mk'.  *Note Instead of Executing the
  7510.      Commands: Instead of Execution.
  7511.  
  7512.    * The concept of doing several things at once (parallelism) exists in
  7513.      many incarnations of `make' and similar programs, though not in the
  7514.      System V or BSD implementations.  *Note Command Execution:
  7515.      Execution.
  7516.  
  7517.    * Modified variable references using pattern substitution come from
  7518.      SunOS 4.  *Note Basics of Variable References: Reference.  This
  7519.      functionality was provided in GNU `make' by the `patsubst'
  7520.      function before the alternate syntax was implemented for
  7521.      compatibility with SunOS 4.  It is not altogether clear who
  7522.      inspired whom, since GNU `make' had `patsubst' before SunOS 4 was
  7523.      released.
  7524.  
  7525.    * The special significance of `+' characters preceding command lines
  7526.      (*note Instead of Executing the Commands: Instead of Execution.) is
  7527.      mandated by `IEEE Standard 1003.2-1992' (POSIX.2).
  7528.  
  7529.    * The `+=' syntax to append to the value of a variable comes from
  7530.      SunOS 4 `make'.  *Note Appending More Text to Variables: Appending.
  7531.  
  7532.    * The syntax `ARCHIVE(MEM1 MEM2...)' to list multiple members in a
  7533.      single archive file comes from SunOS 4 `make'.  *Note Archive
  7534.      Members::.
  7535.  
  7536.    * The `-include' directive to include makefiles with no error for a
  7537.      nonexistent file comes from SunOS 4 `make'.  (But note that SunOS 4
  7538.      `make' does not allow multiple makefiles to be specified in one
  7539.      `-include' directive.)  The same feature appears with the name
  7540.      `sinclude' in SGI `make' and perhaps others.
  7541.  
  7542.    The remaining features are inventions new in GNU `make':
  7543.  
  7544.    * Use the `-v' or `--version' option to print version and copyright
  7545.      information.
  7546.  
  7547.    * Use the `-h' or `--help' option to summarize the options to `make'.
  7548.  
  7549.    * Simply-expanded variables.  *Note The Two Flavors of Variables:
  7550.      Flavors.
  7551.  
  7552.    * Pass command-line variable assignments automatically through the
  7553.      variable `MAKE' to recursive `make' invocations.  *Note Recursive
  7554.      Use of `make': Recursion.
  7555.  
  7556.    * Use the `-C' or `--directory' command option to change directory.
  7557.      *Note Summary of Options: Options Summary.
  7558.  
  7559.    * Make verbatim variable definitions with `define'.  *Note Defining
  7560.      Variables Verbatim: Defining.
  7561.  
  7562.    * Declare phony targets with the special target `.PHONY'.
  7563.  
  7564.      Andrew Hume of AT&T Bell Labs implemented a similar feature with a
  7565.      different syntax in his `mk' program.  This seems to be a case of
  7566.      parallel discovery.  *Note Phony Targets: Phony Targets.
  7567.  
  7568.    * Manipulate text by calling functions.  *Note Functions for
  7569.      Transforming Text: Functions.
  7570.  
  7571.    * Use the `-o' or `--old-file' option to pretend a file's
  7572.      modification-time is old.  *Note Avoiding Recompilation of Some
  7573.      Files: Avoiding Compilation.
  7574.  
  7575.    * Conditional execution.
  7576.  
  7577.      This feature has been implemented numerous times in various
  7578.      versions of `make'; it seems a natural extension derived from the
  7579.      features of the C preprocessor and similar macro languages and is
  7580.      not a revolutionary concept.  *Note Conditional Parts of
  7581.      Makefiles: Conditionals.
  7582.  
  7583.    * Specify a search path for included makefiles.  *Note Including
  7584.      Other Makefiles: Include.
  7585.  
  7586.    * Specify extra makefiles to read with an environment variable.
  7587.      *Note The Variable `MAKEFILES': MAKEFILES Variable.
  7588.  
  7589.    * Strip leading sequences of `./' from file names, so that `./FILE'
  7590.      and `FILE' are considered to be the same file.
  7591.  
  7592.    * Use a special search method for library prerequisites written in
  7593.      the form `-lNAME'.  *Note Directory Search for Link Libraries:
  7594.      Libraries/Search.
  7595.  
  7596.    * Allow suffixes for suffix rules (*note Old-Fashioned Suffix Rules:
  7597.      Suffix Rules.) to contain any characters.  In other versions of
  7598.      `make', they must begin with `.' and not contain any `/'
  7599.      characters.
  7600.  
  7601.    * Keep track of the current level of `make' recursion using the
  7602.      variable `MAKELEVEL'.  *Note Recursive Use of `make': Recursion.
  7603.  
  7604.    * Provide any goals given on the command line in the variable
  7605.      `MAKECMDGOALS'.  *Note Arguments to Specify the Goals: Goals.
  7606.  
  7607.    * Specify static pattern rules.  *Note Static Pattern Rules: Static
  7608.      Pattern.
  7609.  
  7610.    * Provide selective `vpath' search.  *Note Searching Directories for
  7611.      Prerequisites: Directory Search.
  7612.  
  7613.    * Provide computed variable references.  *Note Basics of Variable
  7614.      References: Reference.
  7615.  
  7616.    * Update makefiles.  *Note How Makefiles Are Remade: Remaking
  7617.      Makefiles.  System V `make' has a very, very limited form of this
  7618.      functionality in that it will check out SCCS files for makefiles.
  7619.  
  7620.    * Various new built-in implicit rules.  *Note Catalogue of Implicit
  7621.      Rules: Catalogue of Rules.
  7622.  
  7623.    * The built-in variable `MAKE_VERSION' gives the version number of
  7624.      `make'.
  7625.  
  7626. 
  7627. File: make,  Node: Missing,  Next: Makefile Conventions,  Prev: Features,  Up: Top
  7628.  
  7629. 13 Incompatibilities and Missing Features
  7630. *****************************************
  7631.  
  7632. The `make' programs in various other systems support a few features
  7633. that are not implemented in GNU `make'.  The POSIX.2 standard (`IEEE
  7634. Standard 1003.2-1992') which specifies `make' does not require any of
  7635. these features.
  7636.  
  7637.    * A target of the form `FILE((ENTRY))' stands for a member of
  7638.      archive file FILE.  The member is chosen, not by name, but by
  7639.      being an object file which defines the linker symbol ENTRY.
  7640.  
  7641.      This feature was not put into GNU `make' because of the
  7642.      nonmodularity of putting knowledge into `make' of the internal
  7643.      format of archive file symbol tables.  *Note Updating Archive
  7644.      Symbol Directories: Archive Symbols.
  7645.  
  7646.    * Suffixes (used in suffix rules) that end with the character `~'
  7647.      have a special meaning to System V `make'; they refer to the SCCS
  7648.      file that corresponds to the file one would get without the `~'.
  7649.      For example, the suffix rule `.c~.o' would make the file `N.o' from
  7650.      the SCCS file `s.N.c'.  For complete coverage, a whole series of
  7651.      such suffix rules is required.  *Note Old-Fashioned Suffix Rules:
  7652.      Suffix Rules.
  7653.  
  7654.      In GNU `make', this entire series of cases is handled by two
  7655.      pattern rules for extraction from SCCS, in combination with the
  7656.      general feature of rule chaining.  *Note Chains of Implicit Rules:
  7657.      Chained Rules.
  7658.  
  7659.    * In System V and 4.3 BSD `make', files found by `VPATH' search
  7660.      (*note Searching Directories for Prerequisites: Directory Search.)
  7661.      have their names changed inside command strings.  We feel it is
  7662.      much cleaner to always use automatic variables and thus make this
  7663.      feature obsolete.
  7664.  
  7665.    * In some Unix `make's, the automatic variable `$*' appearing in the
  7666.      prerequisites of a rule has the amazingly strange "feature" of
  7667.      expanding to the full name of the _target of that rule_.  We cannot
  7668.      imagine what went on in the minds of Unix `make' developers to do
  7669.      this; it is utterly inconsistent with the normal definition of
  7670.      `$*'.  
  7671.  
  7672.    * In some Unix `make's, implicit rule search (*note Using Implicit
  7673.      Rules: Implicit Rules.) is apparently done for _all_ targets, not
  7674.      just those without commands.  This means you can do:
  7675.  
  7676.           foo.o:
  7677.                   cc -c foo.c
  7678.  
  7679.      and Unix `make' will intuit that `foo.o' depends on `foo.c'.
  7680.  
  7681.      We feel that such usage is broken.  The prerequisite properties of
  7682.      `make' are well-defined (for GNU `make', at least), and doing such
  7683.      a thing simply does not fit the model.
  7684.  
  7685.    * GNU `make' does not include any built-in implicit rules for
  7686.      compiling or preprocessing EFL programs.  If we hear of anyone who
  7687.      is using EFL, we will gladly add them.
  7688.  
  7689.    * It appears that in SVR4 `make', a suffix rule can be specified with
  7690.      no commands, and it is treated as if it had empty commands (*note
  7691.      Empty Commands::).  For example:
  7692.  
  7693.           .c.a:
  7694.  
  7695.      will override the built-in `.c.a' suffix rule.
  7696.  
  7697.      We feel that it is cleaner for a rule without commands to always
  7698.      simply add to the prerequisite list for the target.  The above
  7699.      example can be easily rewritten to get the desired behavior in GNU
  7700.      `make':
  7701.  
  7702.           .c.a: ;
  7703.  
  7704.    * Some versions of `make' invoke the shell with the `-e' flag,
  7705.      except under `-k' (*note Testing the Compilation of a Program:
  7706.      Testing.).  The `-e' flag tells the shell to exit as soon as any
  7707.      program it runs returns a nonzero status.  We feel it is cleaner to
  7708.      write each shell command line to stand on its own and not require
  7709.      this special treatment.
  7710.  
  7711. 
  7712. File: make,  Node: Makefile Conventions,  Next: Quick Reference,  Prev: Missing,  Up: Top
  7713.  
  7714. 14 Makefile Conventions
  7715. ***********************
  7716.  
  7717. This node describes conventions for writing the Makefiles for GNU
  7718. programs.  Using Automake will help you write a Makefile that follows
  7719. these conventions.
  7720.  
  7721. * Menu:
  7722.  
  7723. * Makefile Basics::             General Conventions for Makefiles
  7724. * Utilities in Makefiles::      Utilities in Makefiles
  7725. * Command Variables::           Variables for Specifying Commands
  7726. * Directory Variables::         Variables for Installation Directories
  7727. * Standard Targets::            Standard Targets for Users
  7728. * Install Command Categories::  Three categories of commands in the `install'
  7729.                                   rule: normal, pre-install and post-install.
  7730.  
  7731. 
  7732. File: make,  Node: Makefile Basics,  Next: Utilities in Makefiles,  Up: Makefile Conventions
  7733.  
  7734. 14.1 General Conventions for Makefiles
  7735. ======================================
  7736.  
  7737. Every Makefile should contain this line:
  7738.  
  7739.      SHELL = /bin/sh
  7740.  
  7741. to avoid trouble on systems where the `SHELL' variable might be
  7742. inherited from the environment.  (This is never a problem with GNU
  7743. `make'.)
  7744.  
  7745.    Different `make' programs have incompatible suffix lists and
  7746. implicit rules, and this sometimes creates confusion or misbehavior.  So
  7747. it is a good idea to set the suffix list explicitly using only the
  7748. suffixes you need in the particular Makefile, like this:
  7749.  
  7750.      .SUFFIXES:
  7751.      .SUFFIXES: .c .o
  7752.  
  7753. The first line clears out the suffix list, the second introduces all
  7754. suffixes which may be subject to implicit rules in this Makefile.
  7755.  
  7756.    Don't assume that `.' is in the path for command execution.  When
  7757. you need to run programs that are a part of your package during the
  7758. make, please make sure that it uses `./' if the program is built as
  7759. part of the make or `$(srcdir)/' if the file is an unchanging part of
  7760. the source code.  Without one of these prefixes, the current search
  7761. path is used.
  7762.  
  7763.    The distinction between `./' (the "build directory") and
  7764. `$(srcdir)/' (the "source directory") is important because users can
  7765. build in a separate directory using the `--srcdir' option to
  7766. `configure'.  A rule of the form:
  7767.  
  7768.      foo.1 : foo.man sedscript
  7769.              sed -e sedscript foo.man > foo.1
  7770.  
  7771. will fail when the build directory is not the source directory, because
  7772. `foo.man' and `sedscript' are in the source directory.
  7773.  
  7774.    When using GNU `make', relying on `VPATH' to find the source file
  7775. will work in the case where there is a single dependency file, since
  7776. the `make' automatic variable `$<' will represent the source file
  7777. wherever it is.  (Many versions of `make' set `$<' only in implicit
  7778. rules.)  A Makefile target like
  7779.  
  7780.      foo.o : bar.c
  7781.              $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
  7782.  
  7783. should instead be written as
  7784.  
  7785.      foo.o : bar.c
  7786.              $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
  7787.  
  7788. in order to allow `VPATH' to work correctly.  When the target has
  7789. multiple dependencies, using an explicit `$(srcdir)' is the easiest way
  7790. to make the rule work well.  For example, the target above for `foo.1'
  7791. is best written as:
  7792.  
  7793.      foo.1 : foo.man sedscript
  7794.              sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@
  7795.  
  7796.    GNU distributions usually contain some files which are not source
  7797. files--for example, Info files, and the output from Autoconf, Automake,
  7798. Bison or Flex.  Since these files normally appear in the source
  7799. directory, they should always appear in the source directory, not in the
  7800. build directory.  So Makefile rules to update them should put the
  7801. updated files in the source directory.
  7802.  
  7803.    However, if a file does not appear in the distribution, then the
  7804. Makefile should not put it in the source directory, because building a
  7805. program in ordinary circumstances should not modify the source directory
  7806. in any way.
  7807.  
  7808.    Try to make the build and installation targets, at least (and all
  7809. their subtargets) work correctly with a parallel `make'.
  7810.  
  7811. 
  7812. File: make,  Node: Utilities in Makefiles,  Next: Command Variables,  Prev: Makefile Basics,  Up: Makefile Conventions
  7813.  
  7814. 14.2 Utilities in Makefiles
  7815. ===========================
  7816.  
  7817. Write the Makefile commands (and any shell scripts, such as
  7818. `configure') to run in `sh', not in `csh'.  Don't use any special
  7819. features of `ksh' or `bash'.
  7820.  
  7821.    The `configure' script and the Makefile rules for building and
  7822. installation should not use any utilities directly except these:
  7823.  
  7824.      cat cmp cp diff echo egrep expr false grep install-info
  7825.      ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
  7826.  
  7827.    The compression program `gzip' can be used in the `dist' rule.
  7828.  
  7829.    Stick to the generally supported options for these programs.  For
  7830. example, don't use `mkdir -p', convenient as it may be, because most
  7831. systems don't support it.
  7832.  
  7833.    It is a good idea to avoid creating symbolic links in makefiles,
  7834. since a few systems don't support them.
  7835.  
  7836.    The Makefile rules for building and installation can also use
  7837. compilers and related programs, but should do so via `make' variables
  7838. so that the user can substitute alternatives.  Here are some of the
  7839. programs we mean:
  7840.  
  7841.      ar bison cc flex install ld ldconfig lex
  7842.      make makeinfo ranlib texi2dvi yacc
  7843.  
  7844.    Use the following `make' variables to run those programs:
  7845.  
  7846.      $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
  7847.      $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
  7848.  
  7849.    When you use `ranlib' or `ldconfig', you should make sure nothing
  7850. bad happens if the system does not have the program in question.
  7851. Arrange to ignore an error from that command, and print a message before
  7852. the command to tell the user that failure of this command does not mean
  7853. a problem.  (The Autoconf `AC_PROG_RANLIB' macro can help with this.)
  7854.  
  7855.    If you use symbolic links, you should implement a fallback for
  7856. systems that don't have symbolic links.
  7857.  
  7858.    Additional utilities that can be used via Make variables are:
  7859.  
  7860.      chgrp chmod chown mknod
  7861.  
  7862.    It is ok to use other utilities in Makefile portions (or scripts)
  7863. intended only for particular systems where you know those utilities
  7864. exist.
  7865.  
  7866. 
  7867. File: make,  Node: Command Variables,  Next: Directory Variables,  Prev: Utilities in Makefiles,  Up: Makefile Conventions
  7868.  
  7869. 14.3 Variables for Specifying Commands
  7870. ======================================
  7871.  
  7872. Makefiles should provide variables for overriding certain commands,
  7873. options, and so on.
  7874.  
  7875.    In particular, you should run most utility programs via variables.
  7876. Thus, if you use Bison, have a variable named `BISON' whose default
  7877. value is set with `BISON = bison', and refer to it with `$(BISON)'
  7878. whenever you need to use Bison.
  7879.  
  7880.    File management utilities such as `ln', `rm', `mv', and so on, need
  7881. not be referred to through variables in this way, since users don't
  7882. need to replace them with other programs.
  7883.  
  7884.    Each program-name variable should come with an options variable that
  7885. is used to supply options to the program.  Append `FLAGS' to the
  7886. program-name variable name to get the options variable name--for
  7887. example, `BISONFLAGS'.  (The names `CFLAGS' for the C compiler,
  7888. `YFLAGS' for yacc, and `LFLAGS' for lex, are exceptions to this rule,
  7889. but we keep them because they are standard.)  Use `CPPFLAGS' in any
  7890. compilation command that runs the preprocessor, and use `LDFLAGS' in
  7891. any compilation command that does linking as well as in any direct use
  7892. of `ld'.
  7893.  
  7894.    If there are C compiler options that _must_ be used for proper
  7895. compilation of certain files, do not include them in `CFLAGS'.  Users
  7896. expect to be able to specify `CFLAGS' freely themselves.  Instead,
  7897. arrange to pass the necessary options to the C compiler independently
  7898. of `CFLAGS', by writing them explicitly in the compilation commands or
  7899. by defining an implicit rule, like this:
  7900.  
  7901.      CFLAGS = -g
  7902.      ALL_CFLAGS = -I. $(CFLAGS)
  7903.      .c.o:
  7904.              $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
  7905.  
  7906.    Do include the `-g' option in `CFLAGS', because that is not
  7907. _required_ for proper compilation.  You can consider it a default that
  7908. is only recommended.  If the package is set up so that it is compiled
  7909. with GCC by default, then you might as well include `-O' in the default
  7910. value of `CFLAGS' as well.
  7911.  
  7912.    Put `CFLAGS' last in the compilation command, after other variables
  7913. containing compiler options, so the user can use `CFLAGS' to override
  7914. the others.
  7915.  
  7916.    `CFLAGS' should be used in every invocation of the C compiler, both
  7917. those which do compilation and those which do linking.
  7918.  
  7919.    Every Makefile should define the variable `INSTALL', which is the
  7920. basic command for installing a file into the system.
  7921.  
  7922.    Every Makefile should also define the variables `INSTALL_PROGRAM'
  7923. and `INSTALL_DATA'.  (The default for `INSTALL_PROGRAM' should be
  7924. `$(INSTALL)'; the default for `INSTALL_DATA' should be `${INSTALL} -m
  7925. 644'.)  Then it should use those variables as the commands for actual
  7926. installation, for executables and nonexecutables respectively.  Use
  7927. these variables as follows:
  7928.  
  7929.      $(INSTALL_PROGRAM) foo $(bindir)/foo
  7930.      $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
  7931.  
  7932.    Optionally, you may prepend the value of `DESTDIR' to the target
  7933. filename.  Doing this allows the installer to create a snapshot of the
  7934. installation to be copied onto the real target filesystem later.  Do not
  7935. set the value of `DESTDIR' in your Makefile, and do not include it in
  7936. any installed files.  With support for `DESTDIR', the above examples
  7937. become:
  7938.  
  7939.      $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
  7940.      $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
  7941.  
  7942. Always use a file name, not a directory name, as the second argument of
  7943. the installation commands.  Use a separate command for each file to be
  7944. installed.
  7945.  
  7946. 
  7947. File: make,  Node: Directory Variables,  Next: Standard Targets,  Prev: Command Variables,  Up: Makefile Conventions
  7948.  
  7949. 14.4 Variables for Installation Directories
  7950. ===========================================
  7951.  
  7952. Installation directories should always be named by variables, so it is
  7953. easy to install in a nonstandard place.  The standard names for these
  7954. variables are described below.  They are based on a standard filesystem
  7955. layout; variants of it are used in SVR4, 4.4BSD, GNU/Linux, Ultrix v4,
  7956. and other modern operating systems.
  7957.  
  7958.    These two variables set the root for the installation.  All the other
  7959. installation directories should be subdirectories of one of these two,
  7960. and nothing should be directly installed into these two directories.
  7961.  
  7962. `prefix'
  7963.      A prefix used in constructing the default values of the variables
  7964.      listed below.  The default value of `prefix' should be
  7965.      `/usr/local'.  When building the complete GNU system, the prefix
  7966.      will be empty and `/usr' will be a symbolic link to `/'.  (If you
  7967.      are using Autoconf, write it as `@prefix@'.)
  7968.  
  7969.      Running `make install' with a different value of `prefix' from the
  7970.      one used to build the program should _not_ recompile the program.
  7971.  
  7972. `exec_prefix'
  7973.      A prefix used in constructing the default values of some of the
  7974.      variables listed below.  The default value of `exec_prefix' should
  7975.      be `$(prefix)'.  (If you are using Autoconf, write it as
  7976.      `@exec_prefix@'.)
  7977.  
  7978.      Generally, `$(exec_prefix)' is used for directories that contain
  7979.      machine-specific files (such as executables and subroutine
  7980.      libraries), while `$(prefix)' is used directly for other
  7981.      directories.
  7982.  
  7983.      Running `make install' with a different value of `exec_prefix'
  7984.      from the one used to build the program should _not_ recompile the
  7985.      program.
  7986.  
  7987.    Executable programs are installed in one of the following
  7988. directories.
  7989.  
  7990. `bindir'
  7991.      The directory for installing executable programs that users can
  7992.      run.  This should normally be `/usr/local/bin', but write it as
  7993.      `$(exec_prefix)/bin'.  (If you are using Autoconf, write it as
  7994.      `@bindir@'.)
  7995.  
  7996. `sbindir'
  7997.      The directory for installing executable programs that can be run
  7998.      from the shell, but are only generally useful to system
  7999.      administrators.  This should normally be `/usr/local/sbin', but
  8000.      write it as `$(exec_prefix)/sbin'.  (If you are using Autoconf,
  8001.      write it as `@sbindir@'.)
  8002.  
  8003. `libexecdir'
  8004.      The directory for installing executable programs to be run by other
  8005.      programs rather than by users.  This directory should normally be
  8006.      `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'.
  8007.      (If you are using Autoconf, write it as `@libexecdir@'.)
  8008.  
  8009.    Data files used by the program during its execution are divided into
  8010. categories in two ways.
  8011.  
  8012.    * Some files are normally modified by programs; others are never
  8013.      normally modified (though users may edit some of these).
  8014.  
  8015.    * Some files are architecture-independent and can be shared by all
  8016.      machines at a site; some are architecture-dependent and can be
  8017.      shared only by machines of the same kind and operating system;
  8018.      others may never be shared between two machines.
  8019.  
  8020.    This makes for six different possibilities.  However, we want to
  8021. discourage the use of architecture-dependent files, aside from object
  8022. files and libraries.  It is much cleaner to make other data files
  8023. architecture-independent, and it is generally not hard.
  8024.  
  8025.    Therefore, here are the variables Makefiles should use to specify
  8026. directories:
  8027.  
  8028. `datadir'
  8029.      The directory for installing read-only architecture independent
  8030.      data files.  This should normally be `/usr/local/share', but write
  8031.      it as `$(prefix)/share'.  (If you are using Autoconf, write it as
  8032.      `@datadir@'.)  As a special exception, see `$(infodir)' and
  8033.      `$(includedir)' below.
  8034.  
  8035. `sysconfdir'
  8036.      The directory for installing read-only data files that pertain to a
  8037.      single machine-that is to say, files for configuring a host.
  8038.      Mailer and network configuration files, `/etc/passwd', and so
  8039.      forth belong here.  All the files in this directory should be
  8040.      ordinary ASCII text files.  This directory should normally be
  8041.      `/usr/local/etc', but write it as `$(prefix)/etc'.  (If you are
  8042.      using Autoconf, write it as `@sysconfdir@'.)
  8043.  
  8044.      Do not install executables here in this directory (they probably
  8045.      belong in `$(libexecdir)' or `$(sbindir)').  Also do not install
  8046.      files that are modified in the normal course of their use (programs
  8047.      whose purpose is to change the configuration of the system
  8048.      excluded).  Those probably belong in `$(localstatedir)'.
  8049.  
  8050. `sharedstatedir'
  8051.      The directory for installing architecture-independent data files
  8052.      which the programs modify while they run.  This should normally be
  8053.      `/usr/local/com', but write it as `$(prefix)/com'.  (If you are
  8054.      using Autoconf, write it as `@sharedstatedir@'.)
  8055.  
  8056. `localstatedir'
  8057.      The directory for installing data files which the programs modify
  8058.      while they run, and that pertain to one specific machine.  Users
  8059.      should never need to modify files in this directory to configure
  8060.      the package's operation; put such configuration information in
  8061.      separate files that go in `$(datadir)' or `$(sysconfdir)'.
  8062.      `$(localstatedir)' should normally be `/usr/local/var', but write
  8063.      it as `$(prefix)/var'.  (If you are using Autoconf, write it as
  8064.      `@localstatedir@'.)
  8065.  
  8066. `libdir'
  8067.      The directory for object files and libraries of object code.  Do
  8068.      not install executables here, they probably ought to go in
  8069.      `$(libexecdir)' instead.  The value of `libdir' should normally be
  8070.      `/usr/local/lib', but write it as `$(exec_prefix)/lib'.  (If you
  8071.      are using Autoconf, write it as `@libdir@'.)
  8072.  
  8073. `infodir'
  8074.      The directory for installing the Info files for this package.  By
  8075.      default, it should be `/usr/local/info', but it should be written
  8076.      as `$(prefix)/info'.  (If you are using Autoconf, write it as
  8077.      `@infodir@'.)
  8078.  
  8079. `lispdir'
  8080.      The directory for installing any Emacs Lisp files in this package.
  8081.      By default, it should be `/usr/local/share/emacs/site-lisp', but
  8082.      it should be written as `$(prefix)/share/emacs/site-lisp'.
  8083.  
  8084.      If you are using Autoconf, write the default as `@lispdir@'.  In
  8085.      order to make `@lispdir@' work, you need the following lines in
  8086.      your `configure.in' file:
  8087.  
  8088.           lispdir='${datadir}/emacs/site-lisp'
  8089.           AC_SUBST(lispdir)
  8090.  
  8091. `includedir'
  8092.      The directory for installing header files to be included by user
  8093.      programs with the C `#include' preprocessor directive.  This
  8094.      should normally be `/usr/local/include', but write it as
  8095.      `$(prefix)/include'.  (If you are using Autoconf, write it as
  8096.      `@includedir@'.)
  8097.  
  8098.      Most compilers other than GCC do not look for header files in
  8099.      directory `/usr/local/include'.  So installing the header files
  8100.      this way is only useful with GCC.  Sometimes this is not a problem
  8101.      because some libraries are only really intended to work with GCC.
  8102.      But some libraries are intended to work with other compilers.
  8103.      They should install their header files in two places, one
  8104.      specified by `includedir' and one specified by `oldincludedir'.
  8105.  
  8106. `oldincludedir'
  8107.      The directory for installing `#include' header files for use with
  8108.      compilers other than GCC.  This should normally be `/usr/include'.
  8109.      (If you are using Autoconf, you can write it as `@oldincludedir@'.)
  8110.  
  8111.      The Makefile commands should check whether the value of
  8112.      `oldincludedir' is empty.  If it is, they should not try to use
  8113.      it; they should cancel the second installation of the header files.
  8114.  
  8115.      A package should not replace an existing header in this directory
  8116.      unless the header came from the same package.  Thus, if your Foo
  8117.      package provides a header file `foo.h', then it should install the
  8118.      header file in the `oldincludedir' directory if either (1) there
  8119.      is no `foo.h' there or (2) the `foo.h' that exists came from the
  8120.      Foo package.
  8121.  
  8122.      To tell whether `foo.h' came from the Foo package, put a magic
  8123.      string in the file--part of a comment--and `grep' for that string.
  8124.  
  8125.    Unix-style man pages are installed in one of the following:
  8126.  
  8127. `mandir'
  8128.      The top-level directory for installing the man pages (if any) for
  8129.      this package.  It will normally be `/usr/local/man', but you should
  8130.      write it as `$(prefix)/man'.  (If you are using Autoconf, write it
  8131.      as `@mandir@'.)
  8132.  
  8133. `man1dir'
  8134.      The directory for installing section 1 man pages.  Write it as
  8135.      `$(mandir)/man1'.
  8136.  
  8137. `man2dir'
  8138.      The directory for installing section 2 man pages.  Write it as
  8139.      `$(mandir)/man2'
  8140.  
  8141. `...'
  8142.      *Don't make the primary documentation for any GNU software be a
  8143.      man page.  Write a manual in Texinfo instead.  Man pages are just
  8144.      for the sake of people running GNU software on Unix, which is a
  8145.      secondary application only.*
  8146.  
  8147. `manext'
  8148.      The file name extension for the installed man page.  This should
  8149.      contain a period followed by the appropriate digit; it should
  8150.      normally be `.1'.
  8151.  
  8152. `man1ext'
  8153.      The file name extension for installed section 1 man pages.
  8154.  
  8155. `man2ext'
  8156.      The file name extension for installed section 2 man pages.
  8157.  
  8158. `...'
  8159.      Use these names instead of `manext' if the package needs to
  8160.      install man pages in more than one section of the manual.
  8161.  
  8162.    And finally, you should set the following variable:
  8163.  
  8164. `srcdir'
  8165.      The directory for the sources being compiled.  The value of this
  8166.      variable is normally inserted by the `configure' shell script.
  8167.      (If you are using Autconf, use `srcdir = @srcdir@'.)
  8168.  
  8169.    For example:
  8170.  
  8171.      # Common prefix for installation directories.
  8172.      # NOTE: This directory must exist when you start the install.
  8173.      prefix = /usr/local
  8174.      exec_prefix = $(prefix)
  8175.      # Where to put the executable for the command `gcc'.
  8176.      bindir = $(exec_prefix)/bin
  8177.      # Where to put the directories used by the compiler.
  8178.      libexecdir = $(exec_prefix)/libexec
  8179.      # Where to put the Info files.
  8180.      infodir = $(prefix)/info
  8181.  
  8182.    If your program installs a large number of files into one of the
  8183. standard user-specified directories, it might be useful to group them
  8184. into a subdirectory particular to that program.  If you do this, you
  8185. should write the `install' rule to create these subdirectories.
  8186.  
  8187.    Do not expect the user to include the subdirectory name in the value
  8188. of any of the variables listed above.  The idea of having a uniform set
  8189. of variable names for installation directories is to enable the user to
  8190. specify the exact same values for several different GNU packages.  In
  8191. order for this to be useful, all the packages must be designed so that
  8192. they will work sensibly when the user does so.
  8193.  
  8194. 
  8195. File: make,  Node: Standard Targets,  Next: Install Command Categories,  Prev: Directory Variables,  Up: Makefile Conventions
  8196.  
  8197. 14.5 Standard Targets for Users
  8198. ===============================
  8199.  
  8200. All GNU programs should have the following targets in their Makefiles:
  8201.  
  8202. `all'
  8203.      Compile the entire program.  This should be the default target.
  8204.      This target need not rebuild any documentation files; Info files
  8205.      should normally be included in the distribution, and DVI files
  8206.      should be made only when explicitly asked for.
  8207.  
  8208.      By default, the Make rules should compile and link with `-g', so
  8209.      that executable programs have debugging symbols.  Users who don't
  8210.      mind being helpless can strip the executables later if they wish.
  8211.  
  8212. `install'
  8213.      Compile the program and copy the executables, libraries, and so on
  8214.      to the file names where they should reside for actual use.  If
  8215.      there is a simple test to verify that a program is properly
  8216.      installed, this target should run that test.
  8217.  
  8218.      Do not strip executables when installing them.  Devil-may-care
  8219.      users can use the `install-strip' target to do that.
  8220.  
  8221.      If possible, write the `install' target rule so that it does not
  8222.      modify anything in the directory where the program was built,
  8223.      provided `make all' has just been done.  This is convenient for
  8224.      building the program under one user name and installing it under
  8225.      another.
  8226.  
  8227.      The commands should create all the directories in which files are
  8228.      to be installed, if they don't already exist.  This includes the
  8229.      directories specified as the values of the variables `prefix' and
  8230.      `exec_prefix', as well as all subdirectories that are needed.  One
  8231.      way to do this is by means of an `installdirs' target as described
  8232.      below.
  8233.  
  8234.      Use `-' before any command for installing a man page, so that
  8235.      `make' will ignore any errors.  This is in case there are systems
  8236.      that don't have the Unix man page documentation system installed.
  8237.  
  8238.      The way to install Info files is to copy them into `$(infodir)'
  8239.      with `$(INSTALL_DATA)' (*note Command Variables::), and then run
  8240.      the `install-info' program if it is present.  `install-info' is a
  8241.      program that edits the Info `dir' file to add or update the menu
  8242.      entry for the given Info file; it is part of the Texinfo package.
  8243.      Here is a sample rule to install an Info file:
  8244.  
  8245.           $(DESTDIR)$(infodir)/foo.info: foo.info
  8246.                   $(POST_INSTALL)
  8247.           # There may be a newer info file in . than in srcdir.
  8248.                   -if test -f foo.info; then d=.; \
  8249.                    else d=$(srcdir); fi; \
  8250.                   $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@; \
  8251.           # Run install-info only if it exists.
  8252.           # Use `if' instead of just prepending `-' to the
  8253.           # line so we notice real errors from install-info.
  8254.           # We use `$(SHELL) -c' because some shells do not
  8255.           # fail gracefully when there is an unknown command.
  8256.                   if $(SHELL) -c 'install-info --version' \
  8257.                      >/dev/null 2>&1; then \
  8258.                     install-info --dir-file=$(DESTDIR)$(infodir)/dir \
  8259.                                  $(DESTDIR)$(infodir)/foo.info; \
  8260.                   else true; fi
  8261.  
  8262.      When writing the `install' target, you must classify all the
  8263.      commands into three categories: normal ones, "pre-installation"
  8264.      commands and "post-installation" commands.  *Note Install Command
  8265.      Categories::.
  8266.  
  8267. `uninstall'
  8268.      Delete all the installed files--the copies that the `install'
  8269.      target creates.
  8270.  
  8271.      This rule should not modify the directories where compilation is
  8272.      done, only the directories where files are installed.
  8273.  
  8274.      The uninstallation commands are divided into three categories,
  8275.      just like the installation commands.  *Note Install Command
  8276.      Categories::.
  8277.  
  8278. `install-strip'
  8279.      Like `install', but strip the executable files while installing
  8280.      them.  In simple cases, this target can use the `install' target in
  8281.      a simple way:
  8282.  
  8283.           install-strip:
  8284.                   $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
  8285.                           install
  8286.  
  8287.      But if the package installs scripts as well as real executables,
  8288.      the `install-strip' target can't just refer to the `install'
  8289.      target; it has to strip the executables but not the scripts.
  8290.  
  8291.      `install-strip' should not strip the executables in the build
  8292.      directory which are being copied for installation.  It should only
  8293.      strip the copies that are installed.
  8294.  
  8295.      Normally we do not recommend stripping an executable unless you
  8296.      are sure the program has no bugs.  However, it can be reasonable
  8297.      to install a stripped executable for actual execution while saving
  8298.      the unstripped executable elsewhere in case there is a bug.
  8299.  
  8300. `clean'
  8301.      Delete all files from the current directory that are normally
  8302.      created by building the program.  Don't delete the files that
  8303.      record the configuration.  Also preserve files that could be made
  8304.      by building, but normally aren't because the distribution comes
  8305.      with them.
  8306.  
  8307.      Delete `.dvi' files here if they are not part of the distribution.
  8308.  
  8309. `distclean'
  8310.      Delete all files from the current directory that are created by
  8311.      configuring or building the program.  If you have unpacked the
  8312.      source and built the program without creating any other files,
  8313.      `make distclean' should leave only the files that were in the
  8314.      distribution.
  8315.  
  8316. `mostlyclean'
  8317.      Like `clean', but may refrain from deleting a few files that people
  8318.      normally don't want to recompile.  For example, the `mostlyclean'
  8319.      target for GCC does not delete `libgcc.a', because recompiling it
  8320.      is rarely necessary and takes a lot of time.
  8321.  
  8322. `maintainer-clean'
  8323.      Delete almost everything from the current directory that can be
  8324.      reconstructed with this Makefile.  This typically includes
  8325.      everything deleted by `distclean', plus more: C source files
  8326.      produced by Bison, tags tables, Info files, and so on.
  8327.  
  8328.      The reason we say "almost everything" is that running the command
  8329.      `make maintainer-clean' should not delete `configure' even if
  8330.      `configure' can be remade using a rule in the Makefile.  More
  8331.      generally, `make maintainer-clean' should not delete anything that
  8332.      needs to exist in order to run `configure' and then begin to build
  8333.      the program.  This is the only exception; `maintainer-clean' should
  8334.      delete everything else that can be rebuilt.
  8335.  
  8336.      The `maintainer-clean' target is intended to be used by a
  8337.      maintainer of the package, not by ordinary users.  You may need
  8338.      special tools to reconstruct some of the files that `make
  8339.      maintainer-clean' deletes.  Since these files are normally
  8340.      included in the distribution, we don't take care to make them easy
  8341.      to reconstruct.  If you find you need to unpack the full
  8342.      distribution again, don't blame us.
  8343.  
  8344.      To help make users aware of this, the commands for the special
  8345.      `maintainer-clean' target should start with these two:
  8346.  
  8347.           @echo 'This command is intended for maintainers to use; it'
  8348.           @echo 'deletes files that may need special tools to rebuild.'
  8349.  
  8350. `TAGS'
  8351.      Update a tags table for this program.
  8352.  
  8353. `info'
  8354.      Generate any Info files needed.  The best way to write the rules
  8355.      is as follows:
  8356.  
  8357.           info: foo.info
  8358.  
  8359.           foo.info: foo.texi chap1.texi chap2.texi
  8360.                   $(MAKEINFO) $(srcdir)/foo.texi
  8361.  
  8362.      You must define the variable `MAKEINFO' in the Makefile.  It should
  8363.      run the `makeinfo' program, which is part of the Texinfo
  8364.      distribution.
  8365.  
  8366.      Normally a GNU distribution comes with Info files, and that means
  8367.      the Info files are present in the source directory.  Therefore,
  8368.      the Make rule for an info file should update it in the source
  8369.      directory.  When users build the package, ordinarily Make will not
  8370.      update the Info files because they will already be up to date.
  8371.  
  8372. `dvi'
  8373.      Generate DVI files for all Texinfo documentation.  For example:
  8374.  
  8375.           dvi: foo.dvi
  8376.  
  8377.           foo.dvi: foo.texi chap1.texi chap2.texi
  8378.                   $(TEXI2DVI) $(srcdir)/foo.texi
  8379.  
  8380.      You must define the variable `TEXI2DVI' in the Makefile.  It should
  8381.      run the program `texi2dvi', which is part of the Texinfo
  8382.      distribution.(1)  Alternatively, write just the dependencies, and
  8383.      allow GNU `make' to provide the command.
  8384.  
  8385. `dist'
  8386.      Create a distribution tar file for this program.  The tar file
  8387.      should be set up so that the file names in the tar file start with
  8388.      a subdirectory name which is the name of the package it is a
  8389.      distribution for.  This name can include the version number.
  8390.  
  8391.      For example, the distribution tar file of GCC version 1.40 unpacks
  8392.      into a subdirectory named `gcc-1.40'.
  8393.  
  8394.      The easiest way to do this is to create a subdirectory
  8395.      appropriately named, use `ln' or `cp' to install the proper files
  8396.      in it, and then `tar' that subdirectory.
  8397.  
  8398.      Compress the tar file with `gzip'.  For example, the actual
  8399.      distribution file for GCC version 1.40 is called `gcc-1.40.tar.gz'.
  8400.  
  8401.      The `dist' target should explicitly depend on all non-source files
  8402.      that are in the distribution, to make sure they are up to date in
  8403.      the distribution.  *Note Making Releases: (standards)Releases.
  8404.  
  8405. `check'
  8406.      Perform self-tests (if any).  The user must build the program
  8407.      before running the tests, but need not install the program; you
  8408.      should write the self-tests so that they work when the program is
  8409.      built but not installed.
  8410.  
  8411.    The following targets are suggested as conventional names, for
  8412. programs in which they are useful.
  8413.  
  8414. `installcheck'
  8415.      Perform installation tests (if any).  The user must build and
  8416.      install the program before running the tests.  You should not
  8417.      assume that `$(bindir)' is in the search path.
  8418.  
  8419. `installdirs'
  8420.      It's useful to add a target named `installdirs' to create the
  8421.      directories where files are installed, and their parent
  8422.      directories.  There is a script called `mkinstalldirs' which is
  8423.      convenient for this; you can find it in the Texinfo package.  You
  8424.      can use a rule like this:
  8425.  
  8426.           # Make sure all installation directories (e.g. $(bindir))
  8427.           # actually exist by making them if necessary.
  8428.           installdirs: mkinstalldirs
  8429.                   $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
  8430.                                           $(libdir) $(infodir) \
  8431.                                           $(mandir)
  8432.  
  8433.      or, if you wish to support `DESTDIR',
  8434.  
  8435.           # Make sure all installation directories (e.g. $(bindir))
  8436.           # actually exist by making them if necessary.
  8437.           installdirs: mkinstalldirs
  8438.                   $(srcdir)/mkinstalldirs \
  8439.                       $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \
  8440.                       $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \
  8441.                       $(DESTDIR)$(mandir)
  8442.  
  8443.      This rule should not modify the directories where compilation is
  8444.      done.  It should do nothing but create installation directories.
  8445.  
  8446.    ---------- Footnotes ----------
  8447.  
  8448.    (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is
  8449. not distributed with Texinfo.
  8450.  
  8451. 
  8452. File: make,  Node: Install Command Categories,  Prev: Standard Targets,  Up: Makefile Conventions
  8453.  
  8454. 14.6 Install Command Categories
  8455. ===============================
  8456.  
  8457. When writing the `install' target, you must classify all the commands
  8458. into three categories: normal ones, "pre-installation" commands and
  8459. "post-installation" commands.
  8460.  
  8461.    Normal commands move files into their proper places, and set their
  8462. modes.  They may not alter any files except the ones that come entirely
  8463. from the package they belong to.
  8464.  
  8465.    Pre-installation and post-installation commands may alter other
  8466. files; in particular, they can edit global configuration files or data
  8467. bases.
  8468.  
  8469.    Pre-installation commands are typically executed before the normal
  8470. commands, and post-installation commands are typically run after the
  8471. normal commands.
  8472.  
  8473.    The most common use for a post-installation command is to run
  8474. `install-info'.  This cannot be done with a normal command, since it
  8475. alters a file (the Info directory) which does not come entirely and
  8476. solely from the package being installed.  It is a post-installation
  8477. command because it needs to be done after the normal command which
  8478. installs the package's Info files.
  8479.  
  8480.    Most programs don't need any pre-installation commands, but we have
  8481. the feature just in case it is needed.
  8482.  
  8483.    To classify the commands in the `install' rule into these three
  8484. categories, insert "category lines" among them.  A category line
  8485. specifies the category for the commands that follow.
  8486.  
  8487.    A category line consists of a tab and a reference to a special Make
  8488. variable, plus an optional comment at the end.  There are three
  8489. variables you can use, one for each category; the variable name
  8490. specifies the category.  Category lines are no-ops in ordinary execution
  8491. because these three Make variables are normally undefined (and you
  8492. _should not_ define them in the makefile).
  8493.  
  8494.    Here are the three possible category lines, each with a comment that
  8495. explains what it means:
  8496.  
  8497.              $(PRE_INSTALL)     # Pre-install commands follow.
  8498.              $(POST_INSTALL)    # Post-install commands follow.
  8499.              $(NORMAL_INSTALL)  # Normal commands follow.
  8500.  
  8501.    If you don't use a category line at the beginning of the `install'
  8502. rule, all the commands are classified as normal until the first category
  8503. line.  If you don't use any category lines, all the commands are
  8504. classified as normal.
  8505.  
  8506.    These are the category lines for `uninstall':
  8507.  
  8508.              $(PRE_UNINSTALL)     # Pre-uninstall commands follow.
  8509.              $(POST_UNINSTALL)    # Post-uninstall commands follow.
  8510.              $(NORMAL_UNINSTALL)  # Normal commands follow.
  8511.  
  8512.    Typically, a pre-uninstall command would be used for deleting entries
  8513. from the Info directory.
  8514.  
  8515.    If the `install' or `uninstall' target has any dependencies which
  8516. act as subroutines of installation, then you should start _each_
  8517. dependency's commands with a category line, and start the main target's
  8518. commands with a category line also.  This way, you can ensure that each
  8519. command is placed in the right category regardless of which of the
  8520. dependencies actually run.
  8521.  
  8522.    Pre-installation and post-installation commands should not run any
  8523. programs except for these:
  8524.  
  8525.      [ basename bash cat chgrp chmod chown cmp cp dd diff echo
  8526.      egrep expand expr false fgrep find getopt grep gunzip gzip
  8527.      hostname install install-info kill ldconfig ln ls md5sum
  8528.      mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
  8529.      test touch true uname xargs yes
  8530.  
  8531.    The reason for distinguishing the commands in this way is for the
  8532. sake of making binary packages.  Typically a binary package contains
  8533. all the executables and other files that need to be installed, and has
  8534. its own method of installing them--so it does not need to run the normal
  8535. installation commands.  But installing the binary package does need to
  8536. execute the pre-installation and post-installation commands.
  8537.  
  8538.    Programs to build binary packages work by extracting the
  8539. pre-installation and post-installation commands.  Here is one way of
  8540. extracting the pre-installation commands:
  8541.  
  8542.      make -n install -o all \
  8543.            PRE_INSTALL=pre-install \
  8544.            POST_INSTALL=post-install \
  8545.            NORMAL_INSTALL=normal-install \
  8546.        | gawk -f pre-install.awk
  8547.  
  8548. where the file `pre-install.awk' could contain this:
  8549.  
  8550.      $0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ {on = 0}
  8551.      on {print $0}
  8552.      $0 ~ /^\t[ \t]*pre_install[ \t]*$/ {on = 1}
  8553.  
  8554.    The resulting file of pre-installation commands is executed as a
  8555. shell script as part of installing the binary package.
  8556.  
  8557. 
  8558. File: make,  Node: Quick Reference,  Next: Error Messages,  Prev: Makefile Conventions,  Up: Top
  8559.  
  8560. Appendix A Quick Reference
  8561. **************************
  8562.  
  8563. This appendix summarizes the directives, text manipulation functions,
  8564. and special variables which GNU `make' understands.  *Note Special
  8565. Targets::, *Note Catalogue of Implicit Rules: Catalogue of Rules, and
  8566. *Note Summary of Options: Options Summary, for other summaries.
  8567.  
  8568.    Here is a summary of the directives GNU `make' recognizes:
  8569.  
  8570. `define VARIABLE'
  8571. `endef'
  8572.      Define a multi-line, recursively-expanded variable.
  8573.      *Note Sequences::.
  8574.  
  8575. `ifdef VARIABLE'
  8576. `ifndef VARIABLE'
  8577. `ifeq (A,B)'
  8578. `ifeq "A" "B"'
  8579. `ifeq 'A' 'B''
  8580. `ifneq (A,B)'
  8581. `ifneq "A" "B"'
  8582. `ifneq 'A' 'B''
  8583. `else'
  8584. `endif'
  8585.      Conditionally evaluate part of the makefile.
  8586.      *Note Conditionals::.
  8587.  
  8588. `include FILE'
  8589. `-include FILE'
  8590. `sinclude FILE'
  8591.      Include another makefile.
  8592.      *Note Including Other Makefiles: Include.
  8593.  
  8594. `override VARIABLE = VALUE'
  8595. `override VARIABLE := VALUE'
  8596. `override VARIABLE += VALUE'
  8597. `override VARIABLE ?= VALUE'
  8598. `override define VARIABLE'
  8599. `endef'
  8600.      Define a variable, overriding any previous definition, even one
  8601.      from the command line.
  8602.      *Note The `override' Directive: Override Directive.
  8603.  
  8604. `export'
  8605.      Tell `make' to export all variables to child processes by default.
  8606.      *Note Communicating Variables to a Sub-`make': Variables/Recursion.
  8607.  
  8608. `export VARIABLE'
  8609. `export VARIABLE = VALUE'
  8610. `export VARIABLE := VALUE'
  8611. `export VARIABLE += VALUE'
  8612. `export VARIABLE ?= VALUE'
  8613. `unexport VARIABLE'
  8614.      Tell `make' whether or not to export a particular variable to child
  8615.      processes.
  8616.      *Note Communicating Variables to a Sub-`make': Variables/Recursion.
  8617.  
  8618. `vpath PATTERN PATH'
  8619.      Specify a search path for files matching a `%' pattern.
  8620.      *Note The `vpath' Directive: Selective Search.
  8621.  
  8622. `vpath PATTERN'
  8623.      Remove all search paths previously specified for PATTERN.
  8624.  
  8625. `vpath'
  8626.      Remove all search paths previously specified in any `vpath'
  8627.      directive.
  8628.  
  8629.    Here is a summary of the text manipulation functions (*note
  8630. Functions::):
  8631.  
  8632. `$(subst FROM,TO,TEXT)'
  8633.      Replace FROM with TO in TEXT.
  8634.      *Note Functions for String Substitution and Analysis: Text
  8635.      Functions.
  8636.  
  8637. `$(patsubst PATTERN,REPLACEMENT,TEXT)'
  8638.      Replace words matching PATTERN with REPLACEMENT in TEXT.
  8639.      *Note Functions for String Substitution and Analysis: Text
  8640.      Functions.
  8641.  
  8642. `$(strip STRING)'
  8643.      Remove excess whitespace characters from STRING.
  8644.      *Note Functions for String Substitution and Analysis: Text
  8645.      Functions.
  8646.  
  8647. `$(findstring FIND,TEXT)'
  8648.      Locate FIND in TEXT.
  8649.      *Note Functions for String Substitution and Analysis: Text
  8650.      Functions.
  8651.  
  8652. `$(filter PATTERN...,TEXT)'
  8653.      Select words in TEXT that match one of the PATTERN words.
  8654.      *Note Functions for String Substitution and Analysis: Text
  8655.      Functions.
  8656.  
  8657. `$(filter-out PATTERN...,TEXT)'
  8658.      Select words in TEXT that _do not_ match any of the PATTERN words.
  8659.      *Note Functions for String Substitution and Analysis: Text
  8660.      Functions.
  8661.  
  8662. `$(sort LIST)'
  8663.      Sort the words in LIST lexicographically, removing duplicates.
  8664.      *Note Functions for String Substitution and Analysis: Text
  8665.      Functions.
  8666.  
  8667. `$(dir NAMES...)'
  8668.      Extract the directory part of each file name.
  8669.      *Note Functions for File Names: File Name Functions.
  8670.  
  8671. `$(notdir NAMES...)'
  8672.      Extract the non-directory part of each file name.
  8673.      *Note Functions for File Names: File Name Functions.
  8674.  
  8675. `$(suffix NAMES...)'
  8676.      Extract the suffix (the last `.' and following characters) of each
  8677.      file name.
  8678.      *Note Functions for File Names: File Name Functions.
  8679.  
  8680. `$(basename NAMES...)'
  8681.      Extract the base name (name without suffix) of each file name.
  8682.      *Note Functions for File Names: File Name Functions.
  8683.  
  8684. `$(addsuffix SUFFIX,NAMES...)'
  8685.      Append SUFFIX to each word in NAMES.
  8686.      *Note Functions for File Names: File Name Functions.
  8687.  
  8688. `$(addprefix PREFIX,NAMES...)'
  8689.      Prepend PREFIX to each word in NAMES.
  8690.      *Note Functions for File Names: File Name Functions.
  8691.  
  8692. `$(join LIST1,LIST2)'
  8693.      Join two parallel lists of words.
  8694.      *Note Functions for File Names: File Name Functions.
  8695.  
  8696. `$(word N,TEXT)'
  8697.      Extract the Nth word (one-origin) of TEXT.
  8698.      *Note Functions for File Names: File Name Functions.
  8699.  
  8700. `$(words TEXT)'
  8701.      Count the number of words in TEXT.
  8702.      *Note Functions for File Names: File Name Functions.
  8703.  
  8704. `$(wordlist S,E,TEXT)'
  8705.      Returns the list of words in TEXT from S to E.
  8706.      *Note Functions for File Names: File Name Functions.
  8707.  
  8708. `$(firstword NAMES...)'
  8709.      Extract the first word of NAMES.
  8710.      *Note Functions for File Names: File Name Functions.
  8711.  
  8712. `$(wildcard PATTERN...)'
  8713.      Find file names matching a shell file name pattern (_not_ a `%'
  8714.      pattern).
  8715.      *Note The Function `wildcard': Wildcard Function.
  8716.  
  8717. `$(error TEXT...)'
  8718.      When this function is evaluated, `make' generates a fatal error
  8719.      with the message TEXT.
  8720.      *Note Functions That Control Make: Make Control Functions.
  8721.  
  8722. `$(warning TEXT...)'
  8723.      When this function is evaluated, `make' generates a warning with
  8724.      the message TEXT.
  8725.      *Note Functions That Control Make: Make Control Functions.
  8726.  
  8727. `$(shell COMMAND)'
  8728.      Execute a shell command and return its output.
  8729.      *Note The `shell' Function: Shell Function.
  8730.  
  8731. `$(origin VARIABLE)'
  8732.      Return a string describing how the `make' variable VARIABLE was
  8733.      defined.
  8734.      *Note The `origin' Function: Origin Function.
  8735.  
  8736. `$(foreach VAR,WORDS,TEXT)'
  8737.      Evaluate TEXT with VAR bound to each word in WORDS, and
  8738.      concatenate the results.
  8739.      *Note The `foreach' Function: Foreach Function.
  8740.  
  8741. `$(call VAR,PARAM,...)'
  8742.      Evaluate the variable VAR replacing any references to `$(1)',
  8743.      `$(2)' with the first, second, etc. PARAM values.
  8744.      *Note The `call' Function: Call Function.
  8745.  
  8746.    Here is a summary of the automatic variables.  *Note Automatic
  8747. Variables: Automatic, for full information.
  8748.  
  8749. `$@'
  8750.      The file name of the target.
  8751.  
  8752. `$%'
  8753.      The target member name, when the target is an archive member.
  8754.  
  8755. `$<'
  8756.      The name of the first prerequisite.
  8757.  
  8758. `$?'
  8759.      The names of all the prerequisites that are newer than the target,
  8760.      with spaces between them.  For prerequisites which are archive
  8761.      members, only the member named is used (*note Archives::).
  8762.  
  8763. `$^'
  8764. `$+'
  8765.      The names of all the prerequisites, with spaces between them.  For
  8766.      prerequisites which are archive members, only the member named is
  8767.      used (*note Archives::).  The value of `$^' omits duplicate
  8768.      prerequisites, while `$+' retains them and preserves their order.
  8769.  
  8770. `$*'
  8771.      The stem with which an implicit rule matches (*note How Patterns
  8772.      Match: Pattern Match.).
  8773.  
  8774. `$(@D)'
  8775. `$(@F)'
  8776.      The directory part and the file-within-directory part of `$@'.
  8777.  
  8778. `$(*D)'
  8779. `$(*F)'
  8780.      The directory part and the file-within-directory part of `$*'.
  8781.  
  8782. `$(%D)'
  8783. `$(%F)'
  8784.      The directory part and the file-within-directory part of `$%'.
  8785.  
  8786. `$(<D)'
  8787. `$(<F)'
  8788.      The directory part and the file-within-directory part of `$<'.
  8789.  
  8790. `$(^D)'
  8791. `$(^F)'
  8792.      The directory part and the file-within-directory part of `$^'.
  8793.  
  8794. `$(+D)'
  8795. `$(+F)'
  8796.      The directory part and the file-within-directory part of `$+'.
  8797.  
  8798. `$(?D)'
  8799. `$(?F)'
  8800.      The directory part and the file-within-directory part of `$?'.
  8801.  
  8802.    These variables are used specially by GNU `make':
  8803.  
  8804. `MAKEFILES'
  8805.      Makefiles to be read on every invocation of `make'.
  8806.      *Note The Variable `MAKEFILES': MAKEFILES Variable.
  8807.  
  8808. `VPATH'
  8809.      Directory search path for files not found in the current directory.
  8810.      *Note `VPATH' Search Path for All Prerequisites: General Search.
  8811.  
  8812. `SHELL'
  8813.      The name of the system default command interpreter, usually
  8814.      `/bin/sh'.  You can set `SHELL' in the makefile to change the
  8815.      shell used to run commands.  *Note Command Execution: Execution.
  8816.  
  8817. `MAKESHELL'
  8818.      On MS-DOS only, the name of the command interpreter that is to be
  8819.      used by `make'. This value takes precedence over the value of
  8820.      `SHELL'.  *Note MAKESHELL variable: Execution.
  8821.  
  8822. `MAKE'
  8823.      The name with which `make' was invoked.  Using this variable in
  8824.      commands has special meaning.  *Note How the `MAKE' Variable
  8825.      Works: MAKE Variable.
  8826.  
  8827. `MAKELEVEL'
  8828.      The number of levels of recursion (sub-`make's).
  8829.      *Note Variables/Recursion::.
  8830.  
  8831. `MAKEFLAGS'
  8832.      The flags given to `make'.  You can set this in the environment or
  8833.      a makefile to set flags.
  8834.      *Note Communicating Options to a Sub-`make': Options/Recursion.
  8835.  
  8836.      It is _never_ appropriate to use `MAKEFLAGS' directly on a command
  8837.      line: its contents may not be quoted correctly for use in the
  8838.      shell.  Always allow recursive `make''s to obtain these values
  8839.      through the environment from its parent.
  8840.  
  8841. `MAKECMDGOALS'
  8842.      The targets given to `make' on the command line.  Setting this
  8843.      variable has no effect on the operation of `make'.
  8844.      *Note Arguments to Specify the Goals: Goals.
  8845.  
  8846. `CURDIR'
  8847.      Set to the pathname of the current working directory (after all
  8848.      `-C' options are processed, if any).  Setting this variable has no
  8849.      effect on the operation of `make'.
  8850.      *Note Recursive Use of `make': Recursion.
  8851.  
  8852. `SUFFIXES'
  8853.      The default list of suffixes before `make' reads any makefiles.
  8854.  
  8855. `.LIBPATTERNS'
  8856.      Defines the naming of the libraries `make' searches for, and their
  8857.      order.
  8858.      *Note Directory Search for Link Libraries: Libraries/Search.
  8859.  
  8860. 
  8861. File: make,  Node: Error Messages,  Next: Complex Makefile,  Prev: Quick Reference,  Up: Top
  8862.  
  8863. Appendix B Errors Generated by Make
  8864. ***********************************
  8865.  
  8866. Here is a list of the more common errors you might see generated by
  8867. `make', and some information about what they mean and how to fix them.
  8868.  
  8869.    Sometimes `make' errors are not fatal, especially in the presence of
  8870. a `-' prefix on a command script line, or the `-k' command line option.
  8871. Errors that are fatal are prefixed with the string `***'.
  8872.  
  8873.    Error messages are all either prefixed with the name of the program
  8874. (usually `make'), or, if the error is found in a makefile, the name of
  8875. the file and linenumber containing the problem.
  8876.  
  8877.    In the table below, these common prefixes are left off.
  8878.  
  8879. `[FOO] Error NN'
  8880. `[FOO] SIGNAL DESCRIPTION'
  8881.      These errors are not really `make' errors at all.  They mean that a
  8882.      program that `make' invoked as part of a command script returned a
  8883.      non-0 error code (`Error NN'), which `make' interprets as failure,
  8884.      or it exited in some other abnormal fashion (with a signal of some
  8885.      type).  *Note Errors in Commands: Errors.
  8886.  
  8887.      If no `***' is attached to the message, then the subprocess failed
  8888.      but the rule in the makefile was prefixed with the `-' special
  8889.      character, so `make' ignored the error.
  8890.  
  8891. `missing separator.  Stop.'
  8892. `missing separator (did you mean TAB instead of 8 spaces?).  Stop.'
  8893.      This means that `make' could not understand much of anything about
  8894.      the command line it just read.  GNU `make' looks for various kinds
  8895.      of separators (`:', `=', TAB characters, etc.) to help it decide
  8896.      what kind of commandline it's seeing.  This means it couldn't find
  8897.      a valid one.
  8898.  
  8899.      One of the most common reasons for this message is that you (or
  8900.      perhaps your oh-so-helpful editor, as is the case with many
  8901.      MS-Windows editors) have attempted to indent your command scripts
  8902.      with spaces instead of a TAB character.  In this case, `make' will
  8903.      use the second form of the error above.  Remember that every line
  8904.      in the command script must begin with a TAB character.  Eight
  8905.      spaces do not count.  *Note Rule Syntax::.
  8906.  
  8907. `commands commence before first target.  Stop.'
  8908. `missing rule before commands.  Stop.'
  8909.      This means the first thing in the makefile seems to be part of a
  8910.      command script: it begins with a TAB character and doesn't appear
  8911.      to be a legal `make' command (such as a variable assignment).
  8912.      Command scripts must always be associated with a target.
  8913.  
  8914.      The second form is generated if the line has a semicolon as the
  8915.      first non-whitespace character; `make' interprets this to mean you
  8916.      left out the "target: prerequisite" section of a rule.  *Note Rule
  8917.      Syntax::.
  8918.  
  8919. `No rule to make target `XXX'.'
  8920. `No rule to make target `XXX', needed by `YYY'.'
  8921.      This means that `make' decided it needed to build a target, but
  8922.      then couldn't find any instructions in the makefile on how to do
  8923.      that, either explicit or implicit (including in the default rules
  8924.      database).
  8925.  
  8926.      If you want that file to be built, you will need to add a rule to
  8927.      your makefile describing how that target can be built.  Other
  8928.      possible sources of this problem are typos in the makefile (if
  8929.      that filename is wrong) or a corrupted source tree (if that file
  8930.      is not supposed to be built, but rather only a prerequisite).
  8931.  
  8932. `No targets specified and no makefile found.  Stop.'
  8933. `No targets.  Stop.'
  8934.      The former means that you didn't provide any targets to be built
  8935.      on the command line, and `make' couldn't find any makefiles to
  8936.      read in.  The latter means that some makefile was found, but it
  8937.      didn't contain any default target and none was given on the
  8938.      command line.  GNU `make' has nothing to do in these situations.
  8939.      *Note Arguments to Specify the Makefile: Makefile Arguments.
  8940.  
  8941. `Makefile `XXX' was not found.'
  8942. `Included makefile `XXX' was not found.'
  8943.      A makefile specified on the command line (first form) or included
  8944.      (second form) was not found.
  8945.  
  8946. `warning: overriding commands for target `XXX''
  8947. `warning: ignoring old commands for target `XXX''
  8948.      GNU `make' allows commands to be specified only once per target
  8949.      (except for double-colon rules).  If you give commands for a target
  8950.      which already has been defined to have commands, this warning is
  8951.      issued and the second set of commands will overwrite the first set.
  8952.      *Note Multiple Rules for One Target: Multiple Rules.
  8953.  
  8954. `Circular XXX <- YYY dependency dropped.'
  8955.      This means that `make' detected a loop in the dependency graph:
  8956.      after tracing the prerequisite YYY of target XXX, and its
  8957.      prerequisites, etc., one of them depended on XXX again.
  8958.  
  8959. `Recursive variable `XXX' references itself (eventually).  Stop.'
  8960.      This means you've defined a normal (recursive) `make' variable XXX
  8961.      that, when it's expanded, will refer to itself (XXX).  This is not
  8962.      allowed; either use simply-expanded variables (`:=') or use the
  8963.      append operator (`+=').  *Note How to Use Variables: Using
  8964.      Variables.
  8965.  
  8966. `Unterminated variable reference.  Stop.'
  8967.      This means you forgot to provide the proper closing parenthesis or
  8968.      brace in your variable or function reference.
  8969.  
  8970. `insufficient arguments to function `XXX'.  Stop.'
  8971.      This means you haven't provided the requisite number of arguments
  8972.      for this function.  See the documentation of the function for a
  8973.      description of its arguments.  *Note Functions for Transforming
  8974.      Text: Functions.
  8975.  
  8976. `missing target pattern.  Stop.'
  8977. `multiple target patterns.  Stop.'
  8978. `target pattern contains no `%'.  Stop.'
  8979. `mixed implicit and static pattern rules.  Stop.'
  8980.      These are generated for malformed static pattern rules.  The first
  8981.      means there's no pattern in the target section of the rule; the
  8982.      second means there are multiple patterns in the target section;
  8983.      the third means the target doesn't contain a pattern character
  8984.      (`%'); and the fourth means that all three parts of the static
  8985.      pattern rule contain pattern characters (`%')-only the first two
  8986.      parts should.  *Note Syntax of Static Pattern Rules: Static Usage.
  8987.  
  8988. `warning: -jN forced in submake: disabling jobserver mode.'
  8989.      This warning and the next are generated if `make' detects error
  8990.      conditions related to parallel processing on systems where
  8991.      sub-`make's can communicate (*note Communicating Options to a
  8992.      Sub-`make': Options/Recursion.).  This warning is generated if a
  8993.      recursive invocation of a `make' process is forced to have `-jN'
  8994.      in its argument list (where N is greater than one).  This could
  8995.      happen, for example, if you set the `MAKE' environment variable to
  8996.      `make -j2'.  In this case, the sub-`make' doesn't communicate with
  8997.      other `make' processes and will simply pretend it has two jobs of
  8998.      its own.
  8999.  
  9000. `warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.'
  9001.      In order for `make' processes to communicate, the parent will pass
  9002.      information to the child.  Since this could result in problems if
  9003.      the child process isn't actually a `make', the parent will only do
  9004.      this if it thinks the child is a `make'.  The parent uses the
  9005.      normal algorithms to determine this (*note How the `MAKE' Variable
  9006.      Works: MAKE Variable.).  If the makefile is constructed such that
  9007.      the parent doesn't know the child is a `make' process, then the
  9008.      child will receive only part of the information necessary.  In
  9009.      this case, the child will generate this warning message and
  9010.      proceed with its build in a sequential manner.
  9011.  
  9012.  
  9013. 
  9014. File: make,  Node: Complex Makefile,  Next: GNU Free Documentation License,  Prev: Error Messages,  Up: Top
  9015.  
  9016. Appendix C Complex Makefile Example
  9017. ***********************************
  9018.  
  9019. Here is the makefile for the GNU `tar' program.  This is a moderately
  9020. complex makefile.
  9021.  
  9022.    Because it is the first target, the default goal is `all'.  An
  9023. interesting feature of this makefile is that `testpad.h' is a source
  9024. file automatically created by the `testpad' program, itself compiled
  9025. from `testpad.c'.
  9026.  
  9027.    If you type `make' or `make all', then `make' creates the `tar'
  9028. executable, the `rmt' daemon that provides remote tape access, and the
  9029. `tar.info' Info file.
  9030.  
  9031.    If you type `make install', then `make' not only creates `tar',
  9032. `rmt', and `tar.info', but also installs them.
  9033.  
  9034.    If you type `make clean', then `make' removes the `.o' files, and
  9035. the `tar', `rmt', `testpad', `testpad.h', and `core' files.
  9036.  
  9037.    If you type `make distclean', then `make' not only removes the same
  9038. files as does `make clean' but also the `TAGS', `Makefile', and
  9039. `config.status' files.  (Although it is not evident, this makefile (and
  9040. `config.status') is generated by the user with the `configure' program,
  9041. which is provided in the `tar' distribution, but is not shown here.)
  9042.  
  9043.    If you type `make realclean', then `make' removes the same files as
  9044. does `make distclean' and also removes the Info files generated from
  9045. `tar.texinfo'.
  9046.  
  9047.    In addition, there are targets `shar' and `dist' that create
  9048. distribution kits.
  9049.  
  9050.      # Generated automatically from Makefile.in by configure.
  9051.      # Un*x Makefile for GNU tar program.
  9052.      # Copyright (C) 1991 Free Software Foundation, Inc.
  9053.  
  9054.      # This program is free software; you can redistribute
  9055.      # it and/or modify it under the terms of the GNU
  9056.      # General Public License ...
  9057.      ...
  9058.      ...
  9059.  
  9060.      SHELL = /bin/sh
  9061.  
  9062.      #### Start of system configuration section. ####
  9063.  
  9064.      srcdir = .
  9065.  
  9066.      # If you use gcc, you should either run the
  9067.      # fixincludes script that comes with it or else use
  9068.      # gcc with the -traditional option.  Otherwise ioctl
  9069.      # calls will be compiled incorrectly on some systems.
  9070.      CC = gcc -O
  9071.      YACC = bison -y
  9072.      INSTALL = /usr/local/bin/install -c
  9073.      INSTALLDATA = /usr/local/bin/install -c -m 644
  9074.  
  9075.      # Things you might add to DEFS:
  9076.      # -DSTDC_HEADERS        If you have ANSI C headers and
  9077.      #                       libraries.
  9078.      # -DPOSIX               If you have POSIX.1 headers and
  9079.      #                       libraries.
  9080.      # -DBSD42               If you have sys/dir.h (unless
  9081.      #                       you use -DPOSIX), sys/file.h,
  9082.      #                       and st_blocks in `struct stat'.
  9083.      # -DUSG                 If you have System V/ANSI C
  9084.      #                       string and memory functions
  9085.      #                       and headers, sys/sysmacros.h,
  9086.      #                       fcntl.h, getcwd, no valloc,
  9087.      #                       and ndir.h (unless
  9088.      #                       you use -DDIRENT).
  9089.      # -DNO_MEMORY_H         If USG or STDC_HEADERS but do not
  9090.      #                       include memory.h.
  9091.      # -DDIRENT              If USG and you have dirent.h
  9092.      #                       instead of ndir.h.
  9093.      # -DSIGTYPE=int         If your signal handlers
  9094.      #                       return int, not void.
  9095.      # -DNO_MTIO             If you lack sys/mtio.h
  9096.      #                       (magtape ioctls).
  9097.      # -DNO_REMOTE           If you do not have a remote shell
  9098.      #                       or rexec.
  9099.      # -DUSE_REXEC           To use rexec for remote tape
  9100.      #                       operations instead of
  9101.      #                       forking rsh or remsh.
  9102.      # -DVPRINTF_MISSING     If you lack vprintf function
  9103.      #                       (but have _doprnt).
  9104.      # -DDOPRNT_MISSING      If you lack _doprnt function.
  9105.      #                       Also need to define
  9106.      #                       -DVPRINTF_MISSING.
  9107.      # -DFTIME_MISSING       If you lack ftime system call.
  9108.      # -DSTRSTR_MISSING      If you lack strstr function.
  9109.      # -DVALLOC_MISSING      If you lack valloc function.
  9110.      # -DMKDIR_MISSING       If you lack mkdir and
  9111.      #                       rmdir system calls.
  9112.      # -DRENAME_MISSING      If you lack rename system call.
  9113.      # -DFTRUNCATE_MISSING   If you lack ftruncate
  9114.      #                       system call.
  9115.      # -DV7                  On Version 7 Unix (not
  9116.      #                       tested in a long time).
  9117.      # -DEMUL_OPEN3          If you lack a 3-argument version
  9118.      #                       of open, and want to emulate it
  9119.      #                       with system calls you do have.
  9120.      # -DNO_OPEN3            If you lack the 3-argument open
  9121.      #                       and want to disable the tar -k
  9122.      #                       option instead of emulating open.
  9123.      # -DXENIX               If you have sys/inode.h
  9124.      #                       and need it 94 to be included.
  9125.  
  9126.      DEFS =  -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \
  9127.              -DVPRINTF_MISSING -DBSD42
  9128.      # Set this to rtapelib.o unless you defined NO_REMOTE,
  9129.      # in which case make it empty.
  9130.      RTAPELIB = rtapelib.o
  9131.      LIBS =
  9132.      DEF_AR_FILE = /dev/rmt8
  9133.      DEFBLOCKING = 20
  9134.  
  9135.      CDEBUG = -g
  9136.      CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
  9137.              -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
  9138.              -DDEFBLOCKING=$(DEFBLOCKING)
  9139.      LDFLAGS = -g
  9140.  
  9141.      prefix = /usr/local
  9142.      # Prefix for each installed program,
  9143.      # normally empty or `g'.
  9144.      binprefix =
  9145.  
  9146.      # The directory to install tar in.
  9147.      bindir = $(prefix)/bin
  9148.  
  9149.      # The directory to install the info files in.
  9150.      infodir = $(prefix)/info
  9151.  
  9152.      #### End of system configuration section. ####
  9153.  
  9154.      SRC1 =  tar.c create.c extract.c buffer.c \
  9155.              getoldopt.c update.c gnu.c mangle.c
  9156.      SRC2 =  version.c list.c names.c diffarch.c \
  9157.              port.c wildmat.c getopt.c
  9158.      SRC3 =  getopt1.c regex.c getdate.y
  9159.      SRCS =  $(SRC1) $(SRC2) $(SRC3)
  9160.      OBJ1 =  tar.o create.o extract.o buffer.o \
  9161.              getoldopt.o update.o gnu.o mangle.o
  9162.      OBJ2 =  version.o list.o names.o diffarch.o \
  9163.              port.o wildmat.o getopt.o
  9164.      OBJ3 =  getopt1.o regex.o getdate.o $(RTAPELIB)
  9165.      OBJS =  $(OBJ1) $(OBJ2) $(OBJ3)
  9166.      AUX =   README COPYING ChangeLog Makefile.in  \
  9167.              makefile.pc configure configure.in \
  9168.              tar.texinfo tar.info* texinfo.tex \
  9169.              tar.h port.h open3.h getopt.h regex.h \
  9170.              rmt.h rmt.c rtapelib.c alloca.c \
  9171.              msd_dir.h msd_dir.c tcexparg.c \
  9172.              level-0 level-1 backup-specs testpad.c
  9173.  
  9174.      all:    tar rmt tar.info
  9175.  
  9176.      tar:    $(OBJS)
  9177.              $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  9178.  
  9179.      rmt:    rmt.c
  9180.              $(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c
  9181.  
  9182.      tar.info: tar.texinfo
  9183.              makeinfo tar.texinfo
  9184.  
  9185.      install: all
  9186.              $(INSTALL) tar $(bindir)/$(binprefix)tar
  9187.              -test ! -f rmt || $(INSTALL) rmt /etc/rmt
  9188.              $(INSTALLDATA) $(srcdir)/tar.info* $(infodir)
  9189.  
  9190.      $(OBJS): tar.h port.h testpad.h
  9191.      regex.o buffer.o tar.o: regex.h
  9192.      # getdate.y has 8 shift/reduce conflicts.
  9193.  
  9194.      testpad.h: testpad
  9195.              ./testpad
  9196.  
  9197.      testpad: testpad.o
  9198.              $(CC) -o $@ testpad.o
  9199.  
  9200.      TAGS:   $(SRCS)
  9201.              etags $(SRCS)
  9202.  
  9203.      clean:
  9204.              rm -f *.o tar rmt testpad testpad.h core
  9205.  
  9206.      distclean: clean
  9207.              rm -f TAGS Makefile config.status
  9208.  
  9209.      realclean: distclean
  9210.              rm -f tar.info*
  9211.  
  9212.      shar: $(SRCS) $(AUX)
  9213.              shar $(SRCS) $(AUX) | compress \
  9214.                > tar-`sed -e '/version_string/!d' \
  9215.                           -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
  9216.                           -e q
  9217.                           version.c`.shar.Z
  9218.  
  9219.      dist: $(SRCS) $(AUX)
  9220.              echo tar-`sed \
  9221.                   -e '/version_string/!d' \
  9222.                   -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
  9223.                   -e q
  9224.                   version.c` > .fname
  9225.              -rm -rf `cat .fname`
  9226.              mkdir `cat .fname`
  9227.              ln $(SRCS) $(AUX) `cat .fname`
  9228.              tar chZf `cat .fname`.tar.Z `cat .fname`
  9229.              -rm -rf `cat .fname` .fname
  9230.  
  9231.      tar.zoo: $(SRCS) $(AUX)
  9232.              -rm -rf tmp.dir
  9233.              -mkdir tmp.dir
  9234.              -rm tar.zoo
  9235.              for X in $(SRCS) $(AUX) ; do \
  9236.                  echo $$X ; \
  9237.                  sed 's/$$/^M/' $$X \
  9238.                  > tmp.dir/$$X ; done
  9239.              cd tmp.dir ; zoo aM ../tar.zoo *
  9240.              -rm -rf tmp.dir
  9241.  
  9242. 
  9243. File: make,  Node: GNU Free Documentation License,  Next: Concept Index,  Prev: Complex Makefile,  Up: Top
  9244.  
  9245. Appendix D GNU Free Documentation License
  9246. *****************************************
  9247.  
  9248.                         Version 1.1, March 2000
  9249.  
  9250.      Copyright (C) 2000 Free Software Foundation, Inc.
  9251.      59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
  9252.  
  9253.      Everyone is permitted to copy and distribute verbatim copies
  9254.      of this license document, but changing it is not allowed.
  9255.  
  9256.   0. PREAMBLE
  9257.  
  9258.      The purpose of this License is to make a manual, textbook, or other
  9259.      written document "free" in the sense of freedom: to assure everyone
  9260.      the effective freedom to copy and redistribute it, with or without
  9261.      modifying it, either commercially or noncommercially.  Secondarily,
  9262.      this License preserves for the author and publisher a way to get
  9263.      credit for their work, while not being considered responsible for
  9264.      modifications made by others.
  9265.  
  9266.      This License is a kind of "copyleft", which means that derivative
  9267.      works of the document must themselves be free in the same sense.
  9268.      It complements the GNU General Public License, which is a copyleft
  9269.      license designed for free software.
  9270.  
  9271.      We have designed this License in order to use it for manuals for
  9272.      free software, because free software needs free documentation: a
  9273.      free program should come with manuals providing the same freedoms
  9274.      that the software does.  But this License is not limited to
  9275.      software manuals; it can be used for any textual work, regardless
  9276.      of subject matter or whether it is published as a printed book.
  9277.      We recommend this License principally for works whose purpose is
  9278.      instruction or reference.
  9279.  
  9280.   1. APPLICABILITY AND DEFINITIONS
  9281.  
  9282.      This License applies to any manual or other work that contains a
  9283.      notice placed by the copyright holder saying it can be distributed
  9284.      under the terms of this License.  The "Document", below, refers to
  9285.      any such manual or work.  Any member of the public is a licensee,
  9286.      and is addressed as "you".
  9287.  
  9288.      A "Modified Version" of the Document means any work containing the
  9289.      Document or a portion of it, either copied verbatim, or with
  9290.      modifications and/or translated into another language.
  9291.  
  9292.      A "Secondary Section" is a named appendix or a front-matter
  9293.      section of the Document that deals exclusively with the
  9294.      relationship of the publishers or authors of the Document to the
  9295.      Document's overall subject (or to related matters) and contains
  9296.      nothing that could fall directly within that overall subject.
  9297.      (For example, if the Document is in part a textbook of
  9298.      mathematics, a Secondary Section may not explain any mathematics.)
  9299.      The relationship could be a matter of historical connection with
  9300.      the subject or with related matters, or of legal, commercial,
  9301.      philosophical, ethical or political position regarding them.
  9302.  
  9303.      The "Invariant Sections" are certain Secondary Sections whose
  9304.      titles are designated, as being those of Invariant Sections, in
  9305.      the notice that says that the Document is released under this
  9306.      License.
  9307.  
  9308.      The "Cover Texts" are certain short passages of text that are
  9309.      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
  9310.      that says that the Document is released under this License.
  9311.  
  9312.      A "Transparent" copy of the Document means a machine-readable copy,
  9313.      represented in a format whose specification is available to the
  9314.      general public, whose contents can be viewed and edited directly
  9315.      and straightforwardly with generic text editors or (for images
  9316.      composed of pixels) generic paint programs or (for drawings) some
  9317.      widely available drawing editor, and that is suitable for input to
  9318.      text formatters or for automatic translation to a variety of
  9319.      formats suitable for input to text formatters.  A copy made in an
  9320.      otherwise Transparent file format whose markup has been designed
  9321.      to thwart or discourage subsequent modification by readers is not
  9322.      Transparent.  A copy that is not "Transparent" is called "Opaque".
  9323.  
  9324.      Examples of suitable formats for Transparent copies include plain
  9325.      ASCII without markup, Texinfo input format, LaTeX input format,
  9326.      SGML or XML using a publicly available DTD, and
  9327.      standard-conforming simple HTML designed for human modification.
  9328.      Opaque formats include PostScript, PDF, proprietary formats that
  9329.      can be read and edited only by proprietary word processors, SGML
  9330.      or XML for which the DTD and/or processing tools are not generally
  9331.      available, and the machine-generated HTML produced by some word
  9332.      processors for output purposes only.
  9333.  
  9334.      The "Title Page" means, for a printed book, the title page itself,
  9335.      plus such following pages as are needed to hold, legibly, the
  9336.      material this License requires to appear in the title page.  For
  9337.      works in formats which do not have any title page as such, "Title
  9338.      Page" means the text near the most prominent appearance of the
  9339.      work's title, preceding the beginning of the body of the text.
  9340.  
  9341.   2. VERBATIM COPYING
  9342.  
  9343.      You may copy and distribute the Document in any medium, either
  9344.      commercially or noncommercially, provided that this License, the
  9345.      copyright notices, and the license notice saying this License
  9346.      applies to the Document are reproduced in all copies, and that you
  9347.      add no other conditions whatsoever to those of this License.  You
  9348.      may not use technical measures to obstruct or control the reading
  9349.      or further copying of the copies you make or distribute.  However,
  9350.      you may accept compensation in exchange for copies.  If you
  9351.      distribute a large enough number of copies you must also follow
  9352.      the conditions in section 3.
  9353.  
  9354.      You may also lend copies, under the same conditions stated above,
  9355.      and you may publicly display copies.
  9356.  
  9357.   3. COPYING IN QUANTITY
  9358.  
  9359.      If you publish printed copies of the Document numbering more than
  9360.      100, and the Document's license notice requires Cover Texts, you
  9361.      must enclose the copies in covers that carry, clearly and legibly,
  9362.      all these Cover Texts: Front-Cover Texts on the front cover, and
  9363.      Back-Cover Texts on the back cover.  Both covers must also clearly
  9364.      and legibly identify you as the publisher of these copies.  The
  9365.      front cover must present the full title with all words of the
  9366.      title equally prominent and visible.  You may add other material
  9367.      on the covers in addition.  Copying with changes limited to the
  9368.      covers, as long as they preserve the title of the Document and
  9369.      satisfy these conditions, can be treated as verbatim copying in
  9370.      other respects.
  9371.  
  9372.      If the required texts for either cover are too voluminous to fit
  9373.      legibly, you should put the first ones listed (as many as fit
  9374.      reasonably) on the actual cover, and continue the rest onto
  9375.      adjacent pages.
  9376.  
  9377.      If you publish or distribute Opaque copies of the Document
  9378.      numbering more than 100, you must either include a
  9379.      machine-readable Transparent copy along with each Opaque copy, or
  9380.      state in or with each Opaque copy a publicly-accessible
  9381.      computer-network location containing a complete Transparent copy
  9382.      of the Document, free of added material, which the general
  9383.      network-using public has access to download anonymously at no
  9384.      charge using public-standard network protocols.  If you use the
  9385.      latter option, you must take reasonably prudent steps, when you
  9386.      begin distribution of Opaque copies in quantity, to ensure that
  9387.      this Transparent copy will remain thus accessible at the stated
  9388.      location until at least one year after the last time you
  9389.      distribute an Opaque copy (directly or through your agents or
  9390.      retailers) of that edition to the public.
  9391.  
  9392.      It is requested, but not required, that you contact the authors of
  9393.      the Document well before redistributing any large number of
  9394.      copies, to give them a chance to provide you with an updated
  9395.      version of the Document.
  9396.  
  9397.   4. MODIFICATIONS
  9398.  
  9399.      You may copy and distribute a Modified Version of the Document
  9400.      under the conditions of sections 2 and 3 above, provided that you
  9401.      release the Modified Version under precisely this License, with
  9402.      the Modified Version filling the role of the Document, thus
  9403.      licensing distribution and modification of the Modified Version to
  9404.      whoever possesses a copy of it.  In addition, you must do these
  9405.      things in the Modified Version:
  9406.  
  9407.        A. Use in the Title Page (and on the covers, if any) a title
  9408.           distinct from that of the Document, and from those of
  9409.           previous versions (which should, if there were any, be listed
  9410.           in the History section of the Document).  You may use the
  9411.           same title as a previous version if the original publisher of
  9412.           that version gives permission.
  9413.  
  9414.        B. List on the Title Page, as authors, one or more persons or
  9415.           entities responsible for authorship of the modifications in
  9416.           the Modified Version, together with at least five of the
  9417.           principal authors of the Document (all of its principal
  9418.           authors, if it has less than five).
  9419.  
  9420.        C. State on the Title page the name of the publisher of the
  9421.           Modified Version, as the publisher.
  9422.  
  9423.        D. Preserve all the copyright notices of the Document.
  9424.  
  9425.        E. Add an appropriate copyright notice for your modifications
  9426.           adjacent to the other copyright notices.
  9427.  
  9428.        F. Include, immediately after the copyright notices, a license
  9429.           notice giving the public permission to use the Modified
  9430.           Version under the terms of this License, in the form shown in
  9431.           the Addendum below.
  9432.  
  9433.        G. Preserve in that license notice the full lists of Invariant
  9434.           Sections and required Cover Texts given in the Document's
  9435.           license notice.
  9436.  
  9437.        H. Include an unaltered copy of this License.
  9438.  
  9439.        I. Preserve the section entitled "History", and its title, and
  9440.           add to it an item stating at least the title, year, new
  9441.           authors, and publisher of the Modified Version as given on
  9442.           the Title Page.  If there is no section entitled "History" in
  9443.           the Document, create one stating the title, year, authors,
  9444.           and publisher of the Document as given on its Title Page,
  9445.           then add an item describing the Modified Version as stated in
  9446.           the previous sentence.
  9447.  
  9448.        J. Preserve the network location, if any, given in the Document
  9449.           for public access to a Transparent copy of the Document, and
  9450.           likewise the network locations given in the Document for
  9451.           previous versions it was based on.  These may be placed in
  9452.           the "History" section.  You may omit a network location for a
  9453.           work that was published at least four years before the
  9454.           Document itself, or if the original publisher of the version
  9455.           it refers to gives permission.
  9456.  
  9457.        K. In any section entitled "Acknowledgments" or "Dedications",
  9458.           preserve the section's title, and preserve in the section all
  9459.           the substance and tone of each of the contributor
  9460.           acknowledgments and/or dedications given therein.
  9461.  
  9462.        L. Preserve all the Invariant Sections of the Document,
  9463.           unaltered in their text and in their titles.  Section numbers
  9464.           or the equivalent are not considered part of the section
  9465.           titles.
  9466.  
  9467.        M. Delete any section entitled "Endorsements".  Such a section
  9468.           may not be included in the Modified Version.
  9469.  
  9470.        N. Do not retitle any existing section as "Endorsements" or to
  9471.           conflict in title with any Invariant Section.
  9472.  
  9473.      If the Modified Version includes new front-matter sections or
  9474.      appendices that qualify as Secondary Sections and contain no
  9475.      material copied from the Document, you may at your option
  9476.      designate some or all of these sections as invariant.  To do this,
  9477.      add their titles to the list of Invariant Sections in the Modified
  9478.      Version's license notice.  These titles must be distinct from any
  9479.      other section titles.
  9480.  
  9481.      You may add a section entitled "Endorsements", provided it contains
  9482.      nothing but endorsements of your Modified Version by various
  9483.      parties--for example, statements of peer review or that the text
  9484.      has been approved by an organization as the authoritative
  9485.      definition of a standard.
  9486.  
  9487.      You may add a passage of up to five words as a Front-Cover Text,
  9488.      and a passage of up to 25 words as a Back-Cover Text, to the end
  9489.      of the list of Cover Texts in the Modified Version.  Only one
  9490.      passage of Front-Cover Text and one of Back-Cover Text may be
  9491.      added by (or through arrangements made by) any one entity.  If the
  9492.      Document already includes a cover text for the same cover,
  9493.      previously added by you or by arrangement made by the same entity
  9494.      you are acting on behalf of, you may not add another; but you may
  9495.      replace the old one, on explicit permission from the previous
  9496.      publisher that added the old one.
  9497.  
  9498.      The author(s) and publisher(s) of the Document do not by this
  9499.      License give permission to use their names for publicity for or to
  9500.      assert or imply endorsement of any Modified Version.
  9501.  
  9502.   5. COMBINING DOCUMENTS
  9503.  
  9504.      You may combine the Document with other documents released under
  9505.      this License, under the terms defined in section 4 above for
  9506.      modified versions, provided that you include in the combination
  9507.      all of the Invariant Sections of all of the original documents,
  9508.      unmodified, and list them all as Invariant Sections of your
  9509.      combined work in its license notice.
  9510.  
  9511.      The combined work need only contain one copy of this License, and
  9512.      multiple identical Invariant Sections may be replaced with a single
  9513.      copy.  If there are multiple Invariant Sections with the same name
  9514.      but different contents, make the title of each such section unique
  9515.      by adding at the end of it, in parentheses, the name of the
  9516.      original author or publisher of that section if known, or else a
  9517.      unique number.  Make the same adjustment to the section titles in
  9518.      the list of Invariant Sections in the license notice of the
  9519.      combined work.
  9520.  
  9521.      In the combination, you must combine any sections entitled
  9522.      "History" in the various original documents, forming one section
  9523.      entitled "History"; likewise combine any sections entitled
  9524.      "Acknowledgments", and any sections entitled "Dedications".  You
  9525.      must delete all sections entitled "Endorsements."
  9526.  
  9527.   6. COLLECTIONS OF DOCUMENTS
  9528.  
  9529.      You may make a collection consisting of the Document and other
  9530.      documents released under this License, and replace the individual
  9531.      copies of this License in the various documents with a single copy
  9532.      that is included in the collection, provided that you follow the
  9533.      rules of this License for verbatim copying of each of the
  9534.      documents in all other respects.
  9535.  
  9536.      You may extract a single document from such a collection, and
  9537.      distribute it individually under this License, provided you insert
  9538.      a copy of this License into the extracted document, and follow
  9539.      this License in all other respects regarding verbatim copying of
  9540.      that document.
  9541.  
  9542.   7. AGGREGATION WITH INDEPENDENT WORKS
  9543.  
  9544.      A compilation of the Document or its derivatives with other
  9545.      separate and independent documents or works, in or on a volume of
  9546.      a storage or distribution medium, does not as a whole count as a
  9547.      Modified Version of the Document, provided no compilation
  9548.      copyright is claimed for the compilation.  Such a compilation is
  9549.      called an "aggregate", and this License does not apply to the
  9550.      other self-contained works thus compiled with the Document, on
  9551.      account of their being thus compiled, if they are not themselves
  9552.      derivative works of the Document.
  9553.  
  9554.      If the Cover Text requirement of section 3 is applicable to these
  9555.      copies of the Document, then if the Document is less than one
  9556.      quarter of the entire aggregate, the Document's Cover Texts may be
  9557.      placed on covers that surround only the Document within the
  9558.      aggregate.  Otherwise they must appear on covers around the whole
  9559.      aggregate.
  9560.  
  9561.   8. TRANSLATION
  9562.  
  9563.      Translation is considered a kind of modification, so you may
  9564.      distribute translations of the Document under the terms of section
  9565.      4.  Replacing Invariant Sections with translations requires special
  9566.      permission from their copyright holders, but you may include
  9567.      translations of some or all Invariant Sections in addition to the
  9568.      original versions of these Invariant Sections.  You may include a
  9569.      translation of this License provided that you also include the
  9570.      original English version of this License.  In case of a
  9571.      disagreement between the translation and the original English
  9572.      version of this License, the original English version will prevail.
  9573.  
  9574.   9. TERMINATION
  9575.  
  9576.      You may not copy, modify, sublicense, or distribute the Document
  9577.      except as expressly provided for under this License.  Any other
  9578.      attempt to copy, modify, sublicense or distribute the Document is
  9579.      void, and will automatically terminate your rights under this
  9580.      License.  However, parties who have received copies, or rights,
  9581.      from you under this License will not have their licenses
  9582.      terminated so long as such parties remain in full compliance.
  9583.  
  9584.  10. FUTURE REVISIONS OF THIS LICENSE
  9585.  
  9586.      The Free Software Foundation may publish new, revised versions of
  9587.      the GNU Free Documentation License from time to time.  Such new
  9588.      versions will be similar in spirit to the present version, but may
  9589.      differ in detail to address new problems or concerns.  See
  9590.      `http://www.gnu.org/copyleft/'.
  9591.  
  9592.      Each version of the License is given a distinguishing version
  9593.      number.  If the Document specifies that a particular numbered
  9594.      version of this License "or any later version" applies to it, you
  9595.      have the option of following the terms and conditions either of
  9596.      that specified version or of any later version that has been
  9597.      published (not as a draft) by the Free Software Foundation.  If
  9598.      the Document does not specify a version number of this License,
  9599.      you may choose any version ever published (not as a draft) by the
  9600.      Free Software Foundation.
  9601.  
  9602. D.1 ADDENDUM: How to use this License for your documents
  9603. ========================================================
  9604.  
  9605. To use this License in a document you have written, include a copy of
  9606. the License in the document and put the following copyright and license
  9607. notices just after the title page:
  9608.  
  9609.        Copyright (C)  YEAR  YOUR NAME.
  9610.        Permission is granted to copy, distribute and/or modify this document
  9611.        under the terms of the GNU Free Documentation License, Version 1.1
  9612.        or any later version published by the Free Software Foundation;
  9613.        with the Invariant Sections being LIST THEIR TITLES, with the
  9614.        Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
  9615.        A copy of the license is included in the section entitled ``GNU
  9616.        Free Documentation License''.
  9617.  
  9618.    If you have no Invariant Sections, write "with no Invariant Sections"
  9619. instead of saying which ones are invariant.  If you have no Front-Cover
  9620. Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
  9621. LIST"; likewise for Back-Cover Texts.
  9622.  
  9623.    If your document contains nontrivial examples of program code, we
  9624. recommend releasing these examples in parallel under your choice of
  9625. free software license, such as the GNU General Public License, to
  9626. permit their use in free software.
  9627.  
  9628. 
  9629. File: make,  Node: Concept Index,  Next: Name Index,  Prev: GNU Free Documentation License,  Up: Top
  9630.  
  9631. Index of Concepts
  9632. *****************
  9633.  
  9634. [index]
  9635. * Menu:
  9636.  
  9637. * # (comments), in commands:             Commands.            (line  18)
  9638. * # (comments), in makefile:             Makefile Contents.   (line  41)
  9639. * #include:                              Automatic Prerequisites.
  9640.                                                               (line  16)
  9641. * $$@, support for:                      Automatic.           (line 151)
  9642. * $, in function call:                   Syntax of Functions. (line   6)
  9643. * $, in rules:                           Rule Syntax.         (line  31)
  9644. * $, in variable name:                   Computed Names.      (line   6)
  9645. * $, in variable reference:              Reference.           (line   6)
  9646. * %, in pattern rules:                   Pattern Intro.       (line   9)
  9647. * %, quoting in patsubst:                Text Functions.      (line  26)
  9648. * %, quoting in static pattern:          Static Usage.        (line  37)
  9649. * %, quoting in vpath:                   Selective Search.    (line  38)
  9650. * %, quoting with \ (backslash) <1>:     Text Functions.      (line  26)
  9651. * %, quoting with \ (backslash) <2>:     Static Usage.        (line  37)
  9652. * %, quoting with \ (backslash):         Selective Search.    (line  38)
  9653. * * (wildcard character):                Wildcards.           (line   6)
  9654. * +, and command execution:              Instead of Execution.
  9655.                                                               (line  58)
  9656. * +, and commands:                       MAKE Variable.       (line  18)
  9657. * +, and define:                         Sequences.           (line  50)
  9658. * +=:                                    Appending.           (line   6)
  9659. * +=, expansion:                         Reading Makefiles.   (line  33)
  9660. * ,v (RCS file extension):               Catalogue of Rules.  (line 157)
  9661. * - (in commands):                       Errors.              (line  19)
  9662. * -, and define:                         Sequences.           (line  50)
  9663. * --always-make:                         Options Summary.     (line  15)
  9664. * --assume-new <1>:                      Options Summary.     (line 229)
  9665. * --assume-new:                          Instead of Execution.
  9666.                                                               (line  33)
  9667. * --assume-new, and recursion:           Options/Recursion.   (line  22)
  9668. * --assume-old <1>:                      Options Summary.     (line 134)
  9669. * --assume-old:                          Avoiding Compilation.
  9670.                                                               (line   6)
  9671. * --assume-old, and recursion:           Options/Recursion.   (line  22)
  9672. * --debug:                               Options Summary.     (line  38)
  9673. * --directory <1>:                       Options Summary.     (line  22)
  9674. * --directory:                           Recursion.           (line  20)
  9675. * --directory, and --print-directory:    -w Option.           (line  20)
  9676. * --directory, and recursion:            Options/Recursion.   (line  22)
  9677. * --dry-run <1>:                         Options Summary.     (line 127)
  9678. * --dry-run <2>:                         Instead of Execution.
  9679.                                                               (line  14)
  9680. * --dry-run:                             Echoing.             (line  18)
  9681. * --environment-overrides:               Options Summary.     (line  74)
  9682. * --file <1>:                            Options Summary.     (line  80)
  9683. * --file <2>:                            Makefile Arguments.  (line   6)
  9684. * --file:                                Makefile Names.      (line  23)
  9685. * --file, and recursion:                 Options/Recursion.   (line  22)
  9686. * --help:                                Options Summary.     (line  86)
  9687. * --ignore-errors <1>:                   Options Summary.     (line  90)
  9688. * --ignore-errors:                       Errors.              (line  30)
  9689. * --include-dir <1>:                     Options Summary.     (line  95)
  9690. * --include-dir:                         Include.             (line  51)
  9691. * --jobs <1>:                            Options Summary.     (line 102)
  9692. * --jobs:                                Parallel.            (line   6)
  9693. * --jobs, and recursion:                 Options/Recursion.   (line  25)
  9694. * --just-print <1>:                      Options Summary.     (line 126)
  9695. * --just-print <2>:                      Instead of Execution.
  9696.                                                               (line  14)
  9697. * --just-print:                          Echoing.             (line  18)
  9698. * --keep-going <1>:                      Options Summary.     (line 111)
  9699. * --keep-going <2>:                      Testing.             (line  16)
  9700. * --keep-going:                          Errors.              (line  47)
  9701. * --load-average <1>:                    Options Summary.     (line 118)
  9702. * --load-average:                        Parallel.            (line  57)
  9703. * --makefile <1>:                        Options Summary.     (line  81)
  9704. * --makefile <2>:                        Makefile Arguments.  (line   6)
  9705. * --makefile:                            Makefile Names.      (line  23)
  9706. * --max-load <1>:                        Options Summary.     (line 119)
  9707. * --max-load:                            Parallel.            (line  57)
  9708. * --new-file <1>:                        Options Summary.     (line 228)
  9709. * --new-file:                            Instead of Execution.
  9710.                                                               (line  33)
  9711. * --new-file, and recursion:             Options/Recursion.   (line  22)
  9712. * --no-builtin-rules:                    Options Summary.     (line 162)
  9713. * --no-builtin-variables:                Options Summary.     (line 175)
  9714. * --no-keep-going:                       Options Summary.     (line 190)
  9715. * --no-print-directory <1>:              Options Summary.     (line 220)
  9716. * --no-print-directory:                  -w Option.           (line  20)
  9717. * --old-file <1>:                        Options Summary.     (line 133)
  9718. * --old-file:                            Avoiding Compilation.
  9719.                                                               (line   6)
  9720. * --old-file, and recursion:             Options/Recursion.   (line  22)
  9721. * --print-data-base:                     Options Summary.     (line 142)
  9722. * --print-directory:                     Options Summary.     (line 212)
  9723. * --print-directory, and --directory:    -w Option.           (line  20)
  9724. * --print-directory, and recursion:      -w Option.           (line  20)
  9725. * --print-directory, disabling:          -w Option.           (line  20)
  9726. * --question <1>:                        Options Summary.     (line 154)
  9727. * --question:                            Instead of Execution.
  9728.                                                               (line  25)
  9729. * --quiet <1>:                           Options Summary.     (line 185)
  9730. * --quiet:                               Echoing.             (line  24)
  9731. * --recon <1>:                           Options Summary.     (line 128)
  9732. * --recon <2>:                           Instead of Execution.
  9733.                                                               (line  14)
  9734. * --recon:                               Echoing.             (line  18)
  9735. * --silent <1>:                          Options Summary.     (line 184)
  9736. * --silent:                              Echoing.             (line  24)
  9737. * --stop:                                Options Summary.     (line 191)
  9738. * --touch <1>:                           Options Summary.     (line 199)
  9739. * --touch:                               Instead of Execution.
  9740.                                                               (line  19)
  9741. * --touch, and recursion:                MAKE Variable.       (line  30)
  9742. * --version:                             Options Summary.     (line 207)
  9743. * --warn-undefined-variables:            Options Summary.     (line 238)
  9744. * --what-if <1>:                         Options Summary.     (line 227)
  9745. * --what-if:                             Instead of Execution.
  9746.                                                               (line  33)
  9747. * -B:                                    Options Summary.     (line  14)
  9748. * -b:                                    Options Summary.     (line   9)
  9749. * -C <1>:                                Options Summary.     (line  21)
  9750. * -C:                                    Recursion.           (line  20)
  9751. * -C, and -w:                            -w Option.           (line  20)
  9752. * -C, and recursion:                     Options/Recursion.   (line  22)
  9753. * -d:                                    Options Summary.     (line  29)
  9754. * -e:                                    Options Summary.     (line  73)
  9755. * -e (shell flag):                       Automatic Prerequisites.
  9756.                                                               (line  66)
  9757. * -f <1>:                                Options Summary.     (line  79)
  9758. * -f <2>:                                Makefile Arguments.  (line   6)
  9759. * -f:                                    Makefile Names.      (line  23)
  9760. * -f, and recursion:                     Options/Recursion.   (line  22)
  9761. * -h:                                    Options Summary.     (line  85)
  9762. * -I:                                    Options Summary.     (line  94)
  9763. * -i <1>:                                Options Summary.     (line  89)
  9764. * -i:                                    Errors.              (line  30)
  9765. * -I:                                    Include.             (line  51)
  9766. * -j <1>:                                Options Summary.     (line 101)
  9767. * -j:                                    Parallel.            (line   6)
  9768. * -j, and archive update:                Archive Pitfalls.    (line   6)
  9769. * -j, and recursion:                     Options/Recursion.   (line  25)
  9770. * -k <1>:                                Options Summary.     (line 110)
  9771. * -k <2>:                                Testing.             (line  16)
  9772. * -k:                                    Errors.              (line  47)
  9773. * -l:                                    Options Summary.     (line 117)
  9774. * -l (library search):                   Libraries/Search.    (line   6)
  9775. * -l (load average):                     Parallel.            (line  57)
  9776. * -m:                                    Options Summary.     (line  10)
  9777. * -M (to compiler):                      Automatic Prerequisites.
  9778.                                                               (line  18)
  9779. * -MM (to GNU compiler):                 Automatic Prerequisites.
  9780.                                                               (line  68)
  9781. * -n <1>:                                Options Summary.     (line 125)
  9782. * -n <2>:                                Instead of Execution.
  9783.                                                               (line  14)
  9784. * -n:                                    Echoing.             (line  18)
  9785. * -o <1>:                                Options Summary.     (line 132)
  9786. * -o:                                    Avoiding Compilation.
  9787.                                                               (line   6)
  9788. * -o, and recursion:                     Options/Recursion.   (line  22)
  9789. * -p:                                    Options Summary.     (line 141)
  9790. * -q <1>:                                Options Summary.     (line 153)
  9791. * -q:                                    Instead of Execution.
  9792.                                                               (line  25)
  9793. * -R:                                    Options Summary.     (line 174)
  9794. * -r:                                    Options Summary.     (line 161)
  9795. * -S:                                    Options Summary.     (line 189)
  9796. * -s <1>:                                Options Summary.     (line 183)
  9797. * -s:                                    Echoing.             (line  24)
  9798. * -t <1>:                                Options Summary.     (line 198)
  9799. * -t:                                    Instead of Execution.
  9800.                                                               (line  19)
  9801. * -t, and recursion:                     MAKE Variable.       (line  30)
  9802. * -v:                                    Options Summary.     (line 206)
  9803. * -W:                                    Options Summary.     (line 226)
  9804. * -w:                                    Options Summary.     (line 211)
  9805. * -W:                                    Instead of Execution.
  9806.                                                               (line  33)
  9807. * -w, and -C:                            -w Option.           (line  20)
  9808. * -w, and recursion:                     -w Option.           (line  20)
  9809. * -W, and recursion:                     Options/Recursion.   (line  22)
  9810. * -w, disabling:                         -w Option.           (line  20)
  9811. * .a (archives):                         Archive Suffix Rules.
  9812.                                                               (line   6)
  9813. * .C:                                    Catalogue of Rules.  (line  33)
  9814. * .c:                                    Catalogue of Rules.  (line  29)
  9815. * .cc:                                   Catalogue of Rules.  (line  33)
  9816. * .ch:                                   Catalogue of Rules.  (line 144)
  9817. * .d:                                    Automatic Prerequisites.
  9818.                                                               (line  81)
  9819. * .def:                                  Catalogue of Rules.  (line  67)
  9820. * .dvi:                                  Catalogue of Rules.  (line 144)
  9821. * .F:                                    Catalogue of Rules.  (line  42)
  9822. * .f:                                    Catalogue of Rules.  (line  42)
  9823. * .info:                                 Catalogue of Rules.  (line 151)
  9824. * .l:                                    Catalogue of Rules.  (line 117)
  9825. * .LIBPATTERNS, and link libraries:      Libraries/Search.    (line   6)
  9826. * .ln:                                   Catalogue of Rules.  (line 139)
  9827. * .mod:                                  Catalogue of Rules.  (line  67)
  9828. * .o:                                    Catalogue of Rules.  (line  29)
  9829. * .p:                                    Catalogue of Rules.  (line  38)
  9830. * .PRECIOUS intermediate files:          Chained Rules.       (line  56)
  9831. * .r:                                    Catalogue of Rules.  (line  42)
  9832. * .S:                                    Catalogue of Rules.  (line  75)
  9833. * .s:                                    Catalogue of Rules.  (line  72)
  9834. * .sh:                                   Catalogue of Rules.  (line 173)
  9835. * .sym:                                  Catalogue of Rules.  (line  67)
  9836. * .tex:                                  Catalogue of Rules.  (line 144)
  9837. * .texi:                                 Catalogue of Rules.  (line 151)
  9838. * .texinfo:                              Catalogue of Rules.  (line 151)
  9839. * .txinfo:                               Catalogue of Rules.  (line 151)
  9840. * .w:                                    Catalogue of Rules.  (line 144)
  9841. * .web:                                  Catalogue of Rules.  (line 144)
  9842. * .y:                                    Catalogue of Rules.  (line 113)
  9843. * :: rules (double-colon):               Double-Colon.        (line   6)
  9844. * := <1>:                                Setting.             (line   6)
  9845. * :=:                                    Flavors.             (line  56)
  9846. * = <1>:                                 Setting.             (line   6)
  9847. * =:                                     Flavors.             (line  10)
  9848. * =, expansion:                          Reading Makefiles.   (line  33)
  9849. * ? (wildcard character):                Wildcards.           (line   6)
  9850. * ?= <1>:                                Setting.             (line   6)
  9851. * ?=:                                    Flavors.             (line 130)
  9852. * ?=, expansion:                         Reading Makefiles.   (line  33)
  9853. * @ (in commands):                       Echoing.             (line   6)
  9854. * @, and define:                         Sequences.           (line  50)
  9855. * [...] (wildcard characters):           Wildcards.           (line   6)
  9856. * \ (backslash), for continuation lines: Simple Makefile.     (line  40)
  9857. * \ (backslash), in commands:            Execution.           (line  20)
  9858. * \ (backslash), to quote % <1>:         Text Functions.      (line  26)
  9859. * \ (backslash), to quote % <2>:         Static Usage.        (line  37)
  9860. * \ (backslash), to quote %:             Selective Search.    (line  38)
  9861. * __.SYMDEF:                             Archive Symbols.     (line   6)
  9862. * algorithm for directory search:        Search Algorithm.    (line   6)
  9863. * all (standard target):                 Goals.               (line  69)
  9864. * appending to variables:                Appending.           (line   6)
  9865. * ar:                                    Implicit Variables.  (line  34)
  9866. * archive:                               Archives.            (line   6)
  9867. * archive member targets:                Archive Members.     (line   6)
  9868. * archive symbol directory updating:     Archive Symbols.     (line   6)
  9869. * archive, and -j:                       Archive Pitfalls.    (line   6)
  9870. * archive, and parallel execution:       Archive Pitfalls.    (line   6)
  9871. * archive, suffix rule for:              Archive Suffix Rules.
  9872.                                                               (line   6)
  9873. * Arg list too long:                     Options/Recursion.   (line  57)
  9874. * arguments of functions:                Syntax of Functions. (line   6)
  9875. * as <1>:                                Implicit Variables.  (line  37)
  9876. * as:                                    Catalogue of Rules.  (line  72)
  9877. * assembly, rule to compile:             Catalogue of Rules.  (line  72)
  9878. * automatic generation of prerequisites <1>: Automatic Prerequisites.
  9879.                                                               (line   6)
  9880. * automatic generation of prerequisites: Include.             (line  49)
  9881. * automatic variables:                   Automatic.           (line   6)
  9882. * backquotes:                            Shell Function.      (line   6)
  9883. * backslash (\), for continuation lines: Simple Makefile.     (line  40)
  9884. * backslash (\), in commands:            Execution.           (line  20)
  9885. * backslash (\), to quote % <1>:         Text Functions.      (line  26)
  9886. * backslash (\), to quote % <2>:         Static Usage.        (line  37)
  9887. * backslash (\), to quote %:             Selective Search.    (line  38)
  9888. * backslashes in pathnames and wildcard expansion: Wildcard Pitfall.
  9889.                                                               (line  31)
  9890. * basename:                              File Name Functions. (line  57)
  9891. * binary packages:                       Install Command Categories.
  9892.                                                               (line  80)
  9893. * broken pipe:                           Parallel.            (line  30)
  9894. * bugs, reporting:                       Bugs.                (line   6)
  9895. * built-in special targets:              Special Targets.     (line   6)
  9896. * C++, rule to compile:                  Catalogue of Rules.  (line  33)
  9897. * C, rule to compile:                    Catalogue of Rules.  (line  29)
  9898. * cc <1>:                                Implicit Variables.  (line  40)
  9899. * cc:                                    Catalogue of Rules.  (line  29)
  9900. * cd (shell command) <1>:                MAKE Variable.       (line  16)
  9901. * cd (shell command):                    Execution.           (line  10)
  9902. * chains of rules:                       Chained Rules.       (line   6)
  9903. * check (standard target):               Goals.               (line 111)
  9904. * clean (standard target):               Goals.               (line  72)
  9905. * clean target <1>:                      Cleanup.             (line  11)
  9906. * clean target:                          Simple Makefile.     (line  83)
  9907. * cleaning up:                           Cleanup.             (line   6)
  9908. * clobber (standard target):             Goals.               (line  83)
  9909. * co <1>:                                Implicit Variables.  (line  46)
  9910. * co:                                    Catalogue of Rules.  (line 157)
  9911. * combining rules by prerequisite:       Combine By Prerequisite.
  9912.                                                               (line   6)
  9913. * command line variable definitions, and recursion: Options/Recursion.
  9914.                                                               (line  17)
  9915. * command line variables:                Overriding.          (line   6)
  9916. * commands:                              Rule Syntax.         (line  26)
  9917. * commands, backslash (\) in:            Execution.           (line  20)
  9918. * commands, comments in:                 Commands.            (line  18)
  9919. * commands, echoing:                     Echoing.             (line   6)
  9920. * commands, empty:                       Empty Commands.      (line   6)
  9921. * commands, errors in:                   Errors.              (line   6)
  9922. * commands, execution:                   Execution.           (line   6)
  9923. * commands, execution in parallel:       Parallel.            (line   6)
  9924. * commands, expansion:                   Shell Function.      (line   6)
  9925. * commands, how to write:                Commands.            (line   6)
  9926. * commands, instead of executing:        Instead of Execution.
  9927.                                                               (line   6)
  9928. * commands, introduction to:             Rule Introduction.   (line   8)
  9929. * commands, quoting newlines in:         Execution.           (line  20)
  9930. * commands, sequences of:                Sequences.           (line   6)
  9931. * comments, in commands:                 Commands.            (line  18)
  9932. * comments, in makefile:                 Makefile Contents.   (line  41)
  9933. * compatibility:                         Features.            (line   6)
  9934. * compatibility in exporting:            Variables/Recursion. (line 100)
  9935. * compilation, testing:                  Testing.             (line   6)
  9936. * computed variable name:                Computed Names.      (line   6)
  9937. * conditional expansion:                 If Function.         (line   6)
  9938. * conditional variable assignment:       Flavors.             (line 130)
  9939. * conditionals:                          Conditionals.        (line   6)
  9940. * continuation lines:                    Simple Makefile.     (line  40)
  9941. * controlling make:                      Make Control Functions.
  9942.                                                               (line   6)
  9943. * conventions for makefiles:             Makefile Conventions.
  9944.                                                               (line   6)
  9945. * ctangle <1>:                           Implicit Variables.  (line  95)
  9946. * ctangle:                               Catalogue of Rules.  (line 144)
  9947. * cweave <1>:                            Implicit Variables.  (line  89)
  9948. * cweave:                                Catalogue of Rules.  (line 144)
  9949. * data base of make rules:               Options Summary.     (line 142)
  9950. * deducing commands (implicit rules):    make Deduces.        (line   6)
  9951. * default directories for included makefiles: Include.        (line  51)
  9952. * default goal <1>:                      Rules.               (line  11)
  9953. * default goal:                          How Make Works.      (line   9)
  9954. * default makefile name:                 Makefile Names.      (line   6)
  9955. * default rules, last-resort:            Last Resort.         (line   6)
  9956. * define, expansion:                     Reading Makefiles.   (line  33)
  9957. * defining variables verbatim:           Defining.            (line   6)
  9958. * deletion of target files <1>:          Interrupts.          (line   6)
  9959. * deletion of target files:              Errors.              (line  64)
  9960. * directive:                             Makefile Contents.   (line  28)
  9961. * directories, printing them:            -w Option.           (line   6)
  9962. * directories, updating archive symbol:  Archive Symbols.     (line   6)
  9963. * directory part:                        File Name Functions. (line  17)
  9964. * directory search (VPATH):              Directory Search.    (line   6)
  9965. * directory search (VPATH), and implicit rules: Implicit/Search.
  9966.                                                               (line   6)
  9967. * directory search (VPATH), and link libraries: Libraries/Search.
  9968.                                                               (line   6)
  9969. * directory search (VPATH), and shell commands: Commands/Search.
  9970.                                                               (line   6)
  9971. * directory search algorithm:            Search Algorithm.    (line   6)
  9972. * directory search, traditional (GPATH): Search Algorithm.    (line  42)
  9973. * dist (standard target):                Goals.               (line 103)
  9974. * distclean (standard target):           Goals.               (line  81)
  9975. * dollar sign ($), in function call:     Syntax of Functions. (line   6)
  9976. * dollar sign ($), in rules:             Rule Syntax.         (line  31)
  9977. * dollar sign ($), in variable name:     Computed Names.      (line   6)
  9978. * dollar sign ($), in variable reference: Reference.          (line   6)
  9979. * double-colon rules:                    Double-Colon.        (line   6)
  9980. * duplicate words, removing:             Text Functions.      (line 155)
  9981. * E2BIG:                                 Options/Recursion.   (line  57)
  9982. * echoing of commands:                   Echoing.             (line   6)
  9983. * editor:                                Introduction.        (line  22)
  9984. * Emacs (M-x compile):                   Errors.              (line  62)
  9985. * empty commands:                        Empty Commands.      (line   6)
  9986. * empty targets:                         Empty Targets.       (line   6)
  9987. * environment:                           Environment.         (line   6)
  9988. * environment, and recursion:            Variables/Recursion. (line   6)
  9989. * environment, SHELL in:                 Execution.           (line  81)
  9990. * error, stopping on:                    Make Control Functions.
  9991.                                                               (line  11)
  9992. * errors (in commands):                  Errors.              (line   6)
  9993. * errors with wildcards:                 Wildcard Pitfall.    (line   6)
  9994. * evaluating makefile syntax:            Eval Function.       (line   6)
  9995. * execution, in parallel:                Parallel.            (line   6)
  9996. * execution, instead of:                 Instead of Execution.
  9997.                                                               (line   6)
  9998. * execution, of commands:                Execution.           (line   6)
  9999. * exit status (errors):                  Errors.              (line   6)
  10000. * explicit rule, definition of:          Makefile Contents.   (line  10)
  10001. * explicit rule, expansion:              Reading Makefiles.   (line  58)
  10002. * exporting variables:                   Variables/Recursion. (line   6)
  10003. * f77 <1>:                               Implicit Variables.  (line  54)
  10004. * f77:                                   Catalogue of Rules.  (line  42)
  10005. * FDL, GNU Free Documentation License:   GNU Free Documentation License.
  10006.                                                               (line   6)
  10007. * features of GNU make:                  Features.            (line   6)
  10008. * features, missing:                     Missing.             (line   6)
  10009. * file name functions:                   File Name Functions. (line   6)
  10010. * file name of makefile:                 Makefile Names.      (line   6)
  10011. * file name of makefile, how to specify: Makefile Names.      (line  30)
  10012. * file name prefix, adding:              File Name Functions. (line  79)
  10013. * file name suffix:                      File Name Functions. (line  43)
  10014. * file name suffix, adding:              File Name Functions. (line  68)
  10015. * file name with wildcards:              Wildcards.           (line   6)
  10016. * file name, basename of:                File Name Functions. (line  57)
  10017. * file name, directory part:             File Name Functions. (line  17)
  10018. * file name, nondirectory part:          File Name Functions. (line  27)
  10019. * files, assuming new:                   Instead of Execution.
  10020.                                                               (line  33)
  10021. * files, assuming old:                   Avoiding Compilation.
  10022.                                                               (line   6)
  10023. * files, avoiding recompilation of:      Avoiding Compilation.
  10024.                                                               (line   6)
  10025. * files, intermediate:                   Chained Rules.       (line  16)
  10026. * filtering out words:                   Text Functions.      (line 132)
  10027. * filtering words:                       Text Functions.      (line 114)
  10028. * finding strings:                       Text Functions.      (line 103)
  10029. * flags:                                 Options Summary.     (line   6)
  10030. * flags for compilers:                   Implicit Variables.  (line   6)
  10031. * flavors of variables:                  Flavors.             (line   6)
  10032. * FORCE:                                 Force Targets.       (line   6)
  10033. * force targets:                         Force Targets.       (line   6)
  10034. * Fortran, rule to compile:              Catalogue of Rules.  (line  42)
  10035. * functions:                             Functions.           (line   6)
  10036. * functions, for controlling make:       Make Control Functions.
  10037.                                                               (line   6)
  10038. * functions, for file names:             File Name Functions. (line   6)
  10039. * functions, for text:                   Text Functions.      (line   6)
  10040. * functions, syntax of:                  Syntax of Functions. (line   6)
  10041. * functions, user defined:               Call Function.       (line   6)
  10042. * g++ <1>:                               Implicit Variables.  (line  43)
  10043. * g++:                                   Catalogue of Rules.  (line  33)
  10044. * gcc:                                   Catalogue of Rules.  (line  29)
  10045. * generating prerequisites automatically <1>: Automatic Prerequisites.
  10046.                                                               (line   6)
  10047. * generating prerequisites automatically: Include.            (line  49)
  10048. * get <1>:                               Implicit Variables.  (line  57)
  10049. * get:                                   Catalogue of Rules.  (line 166)
  10050. * globbing (wildcards):                  Wildcards.           (line   6)
  10051. * goal:                                  How Make Works.      (line   9)
  10052. * goal, default <1>:                     Rules.               (line  11)
  10053. * goal, default:                         How Make Works.      (line   9)
  10054. * goal, how to specify:                  Goals.               (line   6)
  10055. * home directory:                        Wildcards.           (line  11)
  10056. * IEEE Standard 1003.2:                  Overview.            (line  13)
  10057. * ifdef, expansion:                      Reading Makefiles.   (line  51)
  10058. * ifeq, expansion:                       Reading Makefiles.   (line  51)
  10059. * ifndef, expansion:                     Reading Makefiles.   (line  51)
  10060. * ifneq, expansion:                      Reading Makefiles.   (line  51)
  10061. * implicit rule:                         Implicit Rules.      (line   6)
  10062. * implicit rule, and directory search:   Implicit/Search.     (line   6)
  10063. * implicit rule, and VPATH:              Implicit/Search.     (line   6)
  10064. * implicit rule, definition of:          Makefile Contents.   (line  16)
  10065. * implicit rule, expansion:              Reading Makefiles.   (line  58)
  10066. * implicit rule, how to use:             Using Implicit.      (line   6)
  10067. * implicit rule, introduction to:        make Deduces.        (line   6)
  10068. * implicit rule, predefined:             Catalogue of Rules.  (line   6)
  10069. * implicit rule, search algorithm:       Implicit Rule Search.
  10070.                                                               (line   6)
  10071. * included makefiles, default directories: Include.           (line  51)
  10072. * including (MAKEFILE_LIST variable):    MAKEFILE_LIST Variable.
  10073.                                                               (line   6)
  10074. * including (MAKEFILES variable):        MAKEFILES Variable.  (line   6)
  10075. * including other makefiles:             Include.             (line   6)
  10076. * incompatibilities:                     Missing.             (line   6)
  10077. * Info, rule to format:                  Catalogue of Rules.  (line 151)
  10078. * install (standard target):             Goals.               (line  89)
  10079. * intermediate files:                    Chained Rules.       (line  16)
  10080. * intermediate files, preserving:        Chained Rules.       (line  46)
  10081. * intermediate targets, explicit:        Special Targets.     (line  44)
  10082. * interrupt:                             Interrupts.          (line   6)
  10083. * job slots:                             Parallel.            (line   6)
  10084. * job slots, and recursion:              Options/Recursion.   (line  25)
  10085. * jobs, limiting based on load:          Parallel.            (line  57)
  10086. * joining lists of words:                File Name Functions. (line  90)
  10087. * killing (interruption):                Interrupts.          (line   6)
  10088. * last-resort default rules:             Last Resort.         (line   6)
  10089. * ld:                                    Catalogue of Rules.  (line  79)
  10090. * lex <1>:                               Implicit Variables.  (line  61)
  10091. * lex:                                   Catalogue of Rules.  (line 117)
  10092. * Lex, rule to run:                      Catalogue of Rules.  (line 117)
  10093. * libraries for linking, directory search: Libraries/Search.  (line   6)
  10094. * library archive, suffix rule for:      Archive Suffix Rules.
  10095.                                                               (line   6)
  10096. * limiting jobs based on load:           Parallel.            (line  57)
  10097. * link libraries, and directory search:  Libraries/Search.    (line   6)
  10098. * link libraries, patterns matching:     Libraries/Search.    (line   6)
  10099. * linking, predefined rule for:          Catalogue of Rules.  (line  79)
  10100. * lint:                                  Catalogue of Rules.  (line 139)
  10101. * lint, rule to run:                     Catalogue of Rules.  (line 139)
  10102. * list of all prerequisites:             Automatic.           (line  49)
  10103. * list of changed prerequisites:         Automatic.           (line  40)
  10104. * load average:                          Parallel.            (line  57)
  10105. * loops in variable expansion:           Flavors.             (line  44)
  10106. * lpr (shell command) <1>:               Empty Targets.       (line  25)
  10107. * lpr (shell command):                   Wildcard Examples.   (line  21)
  10108. * m2c:                                   Catalogue of Rules.  (line  67)
  10109. * macro:                                 Using Variables.     (line  10)
  10110. * make depend:                           Automatic Prerequisites.
  10111.                                                               (line  37)
  10112. * MAKECMDGOALS:                          Goals.               (line  27)
  10113. * makefile:                              Introduction.        (line   7)
  10114. * makefile name:                         Makefile Names.      (line   6)
  10115. * makefile name, how to specify:         Makefile Names.      (line  30)
  10116. * makefile rule parts:                   Rule Introduction.   (line   6)
  10117. * makefile syntax, evaluating:           Eval Function.       (line   6)
  10118. * makefile, and MAKEFILES variable:      MAKEFILES Variable.  (line   6)
  10119. * makefile, conventions for:             Makefile Conventions.
  10120.                                                               (line   6)
  10121. * makefile, how make processes:          How Make Works.      (line   6)
  10122. * makefile, how to write:                Makefiles.           (line   6)
  10123. * makefile, including:                   Include.             (line   6)
  10124. * makefile, overriding:                  Overriding Makefiles.
  10125.                                                               (line   6)
  10126. * makefile, parsing:                     Reading Makefiles.   (line   6)
  10127. * makefile, remaking of:                 Remaking Makefiles.  (line   6)
  10128. * makefile, simple:                      Simple Makefile.     (line   6)
  10129. * makefiles, and MAKEFILE_LIST variable: MAKEFILE_LIST Variable.
  10130.                                                               (line   6)
  10131. * makefiles, and special variables:      Special Variables.   (line   6)
  10132. * makeinfo <1>:                          Implicit Variables.  (line  76)
  10133. * makeinfo:                              Catalogue of Rules.  (line 151)
  10134. * match-anything rule:                   Match-Anything Rules.
  10135.                                                               (line   6)
  10136. * match-anything rule, used to override: Overriding Makefiles.
  10137.                                                               (line  12)
  10138. * missing features:                      Missing.             (line   6)
  10139. * mistakes with wildcards:               Wildcard Pitfall.    (line   6)
  10140. * modified variable reference:           Substitution Refs.   (line   6)
  10141. * Modula-2, rule to compile:             Catalogue of Rules.  (line  67)
  10142. * mostlyclean (standard target):         Goals.               (line  75)
  10143. * multiple rules for one target:         Multiple Rules.      (line   6)
  10144. * multiple rules for one target (::):    Double-Colon.        (line   6)
  10145. * multiple targets:                      Multiple Targets.    (line   6)
  10146. * multiple targets, in pattern rule:     Pattern Intro.       (line  48)
  10147. * name of makefile:                      Makefile Names.      (line   6)
  10148. * name of makefile, how to specify:      Makefile Names.      (line  30)
  10149. * nested variable reference:             Computed Names.      (line   6)
  10150. * newline, quoting, in commands:         Execution.           (line  20)
  10151. * newline, quoting, in makefile:         Simple Makefile.     (line  40)
  10152. * nondirectory part:                     File Name Functions. (line  27)
  10153. * normal prerequisites:                  Prerequisite Types.  (line   6)
  10154. * OBJ:                                   Variables Simplify.  (line  20)
  10155. * obj:                                   Variables Simplify.  (line  20)
  10156. * OBJECTS:                               Variables Simplify.  (line  20)
  10157. * objects:                               Variables Simplify.  (line  14)
  10158. * OBJS:                                  Variables Simplify.  (line  20)
  10159. * objs:                                  Variables Simplify.  (line  20)
  10160. * old-fashioned suffix rules:            Suffix Rules.        (line   6)
  10161. * options:                               Options Summary.     (line   6)
  10162. * options, and recursion:                Options/Recursion.   (line   6)
  10163. * options, setting from environment:     Options/Recursion.   (line  81)
  10164. * options, setting in makefiles:         Options/Recursion.   (line  81)
  10165. * order of pattern rules:                Pattern Intro.       (line  56)
  10166. * order-only prerequisites:              Prerequisite Types.  (line   6)
  10167. * origin of variable:                    Origin Function.     (line   6)
  10168. * overriding makefiles:                  Overriding Makefiles.
  10169.                                                               (line   6)
  10170. * overriding variables with arguments:   Overriding.          (line   6)
  10171. * overriding with override:              Override Directive.  (line   6)
  10172. * parallel execution:                    Parallel.            (line   6)
  10173. * parallel execution, and archive update: Archive Pitfalls.   (line   6)
  10174. * parallel execution, overriding:        Special Targets.     (line 125)
  10175. * parts of makefile rule:                Rule Introduction.   (line   6)
  10176. * Pascal, rule to compile:               Catalogue of Rules.  (line  38)
  10177. * pattern rule:                          Pattern Intro.       (line   6)
  10178. * pattern rule, expansion:               Reading Makefiles.   (line  58)
  10179. * pattern rules, order of:               Pattern Intro.       (line  56)
  10180. * pattern rules, static (not implicit):  Static Pattern.      (line   6)
  10181. * pattern rules, static, syntax of:      Static Usage.        (line   6)
  10182. * pattern-specific variables:            Pattern-specific.    (line   6)
  10183. * pc <1>:                                Implicit Variables.  (line  64)
  10184. * pc:                                    Catalogue of Rules.  (line  38)
  10185. * phony targets:                         Phony Targets.       (line   6)
  10186. * pitfalls of wildcards:                 Wildcard Pitfall.    (line   6)
  10187. * portability:                           Features.            (line   6)
  10188. * POSIX:                                 Overview.            (line  13)
  10189. * POSIX.2:                               Options/Recursion.   (line  60)
  10190. * post-installation commands:            Install Command Categories.
  10191.                                                               (line   6)
  10192. * pre-installation commands:             Install Command Categories.
  10193.                                                               (line   6)
  10194. * precious targets:                      Special Targets.     (line  29)
  10195. * predefined rules and variables, printing: Options Summary.  (line 142)
  10196. * prefix, adding:                        File Name Functions. (line  79)
  10197. * prerequisite:                          Rules.               (line   6)
  10198. * prerequisite pattern, implicit:        Pattern Intro.       (line  21)
  10199. * prerequisite pattern, static (not implicit): Static Usage.  (line  30)
  10200. * prerequisite types:                    Prerequisite Types.  (line   6)
  10201. * prerequisite, expansion:               Reading Makefiles.   (line  58)
  10202. * prerequisites:                         Rule Syntax.         (line  41)
  10203. * prerequisites, automatic generation <1>: Automatic Prerequisites.
  10204.                                                               (line   6)
  10205. * prerequisites, automatic generation:   Include.             (line  49)
  10206. * prerequisites, introduction to:        Rule Introduction.   (line   8)
  10207. * prerequisites, list of all:            Automatic.           (line  49)
  10208. * prerequisites, list of changed:        Automatic.           (line  40)
  10209. * prerequisites, normal:                 Prerequisite Types.  (line   6)
  10210. * prerequisites, order-only:             Prerequisite Types.  (line   6)
  10211. * prerequisites, varying (static pattern): Static Pattern.    (line   6)
  10212. * preserving intermediate files:         Chained Rules.       (line  46)
  10213. * preserving with .PRECIOUS <1>:         Chained Rules.       (line  56)
  10214. * preserving with .PRECIOUS:             Special Targets.     (line  29)
  10215. * preserving with .SECONDARY:            Special Targets.     (line  49)
  10216. * print (standard target):               Goals.               (line  94)
  10217. * print target <1>:                      Empty Targets.       (line  25)
  10218. * print target:                          Wildcard Examples.   (line  21)
  10219. * printing directories:                  -w Option.           (line   6)
  10220. * printing of commands:                  Echoing.             (line   6)
  10221. * printing user warnings:                Make Control Functions.
  10222.                                                               (line  35)
  10223. * problems and bugs, reporting:          Bugs.                (line   6)
  10224. * problems with wildcards:               Wildcard Pitfall.    (line   6)
  10225. * processing a makefile:                 How Make Works.      (line   6)
  10226. * question mode:                         Instead of Execution.
  10227.                                                               (line  25)
  10228. * quoting %, in patsubst:                Text Functions.      (line  26)
  10229. * quoting %, in static pattern:          Static Usage.        (line  37)
  10230. * quoting %, in vpath:                   Selective Search.    (line  38)
  10231. * quoting newline, in commands:          Execution.           (line  20)
  10232. * quoting newline, in makefile:          Simple Makefile.     (line  40)
  10233. * Ratfor, rule to compile:               Catalogue of Rules.  (line  42)
  10234. * RCS, rule to extract from:             Catalogue of Rules.  (line 157)
  10235. * reading makefiles:                     Reading Makefiles.   (line   6)
  10236. * README:                                Makefile Names.      (line   9)
  10237. * realclean (standard target):           Goals.               (line  82)
  10238. * recompilation:                         Introduction.        (line  22)
  10239. * recompilation, avoiding:               Avoiding Compilation.
  10240.                                                               (line   6)
  10241. * recording events with empty targets:   Empty Targets.       (line   6)
  10242. * recursion:                             Recursion.           (line   6)
  10243. * recursion, and -C:                     Options/Recursion.   (line  22)
  10244. * recursion, and -f:                     Options/Recursion.   (line  22)
  10245. * recursion, and -j:                     Options/Recursion.   (line  25)
  10246. * recursion, and -o:                     Options/Recursion.   (line  22)
  10247. * recursion, and -t:                     MAKE Variable.       (line  30)
  10248. * recursion, and -w:                     -w Option.           (line  20)
  10249. * recursion, and -W:                     Options/Recursion.   (line  22)
  10250. * recursion, and command line variable definitions: Options/Recursion.
  10251.                                                               (line  17)
  10252. * recursion, and environment:            Variables/Recursion. (line   6)
  10253. * recursion, and MAKE variable:          MAKE Variable.       (line   6)
  10254. * recursion, and MAKEFILES variable:     MAKEFILES Variable.  (line  14)
  10255. * recursion, and options:                Options/Recursion.   (line   6)
  10256. * recursion, and printing directories:   -w Option.           (line   6)
  10257. * recursion, and variables:              Variables/Recursion. (line   6)
  10258. * recursion, level of:                   Variables/Recursion. (line 110)
  10259. * recursive variable expansion <1>:      Flavors.             (line   6)
  10260. * recursive variable expansion:          Using Variables.     (line   6)
  10261. * recursively expanded variables:        Flavors.             (line   6)
  10262. * reference to variables <1>:            Advanced.            (line   6)
  10263. * reference to variables:                Reference.           (line   6)
  10264. * relinking:                             How Make Works.      (line  44)
  10265. * remaking makefiles:                    Remaking Makefiles.  (line   6)
  10266. * removal of target files <1>:           Interrupts.          (line   6)
  10267. * removal of target files:               Errors.              (line  64)
  10268. * removing duplicate words:              Text Functions.      (line 155)
  10269. * removing targets on failure:           Special Targets.     (line  58)
  10270. * removing, to clean up:                 Cleanup.             (line   6)
  10271. * reporting bugs:                        Bugs.                (line   6)
  10272. * rm:                                    Implicit Variables.  (line  98)
  10273. * rm (shell command) <1>:                Errors.              (line  27)
  10274. * rm (shell command) <2>:                Phony Targets.       (line  20)
  10275. * rm (shell command) <3>:                Wildcard Examples.   (line  12)
  10276. * rm (shell command):                    Simple Makefile.     (line  83)
  10277. * rule commands:                         Commands.            (line   6)
  10278. * rule prerequisites:                    Rule Syntax.         (line  41)
  10279. * rule syntax:                           Rule Syntax.         (line   6)
  10280. * rule targets:                          Rule Syntax.         (line  18)
  10281. * rule, and $:                           Rule Syntax.         (line  31)
  10282. * rule, double-colon (::):               Double-Colon.        (line   6)
  10283. * rule, explicit, definition of:         Makefile Contents.   (line  10)
  10284. * rule, how to write:                    Rules.               (line   6)
  10285. * rule, implicit:                        Implicit Rules.      (line   6)
  10286. * rule, implicit, and directory search:  Implicit/Search.     (line   6)
  10287. * rule, implicit, and VPATH:             Implicit/Search.     (line   6)
  10288. * rule, implicit, chains of:             Chained Rules.       (line   6)
  10289. * rule, implicit, definition of:         Makefile Contents.   (line  16)
  10290. * rule, implicit, how to use:            Using Implicit.      (line   6)
  10291. * rule, implicit, introduction to:       make Deduces.        (line   6)
  10292. * rule, implicit, predefined:            Catalogue of Rules.  (line   6)
  10293. * rule, introduction to:                 Rule Introduction.   (line   6)
  10294. * rule, multiple for one target:         Multiple Rules.      (line   6)
  10295. * rule, no commands or prerequisites:    Force Targets.       (line   6)
  10296. * rule, pattern:                         Pattern Intro.       (line   6)
  10297. * rule, static pattern:                  Static Pattern.      (line   6)
  10298. * rule, static pattern versus implicit:  Static versus Implicit.
  10299.                                                               (line   6)
  10300. * rule, with multiple targets:           Multiple Targets.    (line   6)
  10301. * s. (SCCS file prefix):                 Catalogue of Rules.  (line 166)
  10302. * SCCS, rule to extract from:            Catalogue of Rules.  (line 166)
  10303. * search algorithm, implicit rule:       Implicit Rule Search.
  10304.                                                               (line   6)
  10305. * search path for prerequisites (VPATH): Directory Search.    (line   6)
  10306. * search path for prerequisites (VPATH), and implicit rules: Implicit/Search.
  10307.                                                               (line   6)
  10308. * search path for prerequisites (VPATH), and link libraries: Libraries/Search.
  10309.                                                               (line   6)
  10310. * searching for strings:                 Text Functions.      (line 103)
  10311. * secondary files:                       Chained Rules.       (line  46)
  10312. * secondary targets:                     Special Targets.     (line  49)
  10313. * sed (shell command):                   Automatic Prerequisites.
  10314.                                                               (line  73)
  10315. * selecting a word:                      Text Functions.      (line 159)
  10316. * selecting word lists:                  Text Functions.      (line 168)
  10317. * sequences of commands:                 Sequences.           (line   6)
  10318. * setting options from environment:      Options/Recursion.   (line  81)
  10319. * setting options in makefiles:          Options/Recursion.   (line  81)
  10320. * setting variables:                     Setting.             (line   6)
  10321. * several rules for one target:          Multiple Rules.      (line   6)
  10322. * several targets in a rule:             Multiple Targets.    (line   6)
  10323. * shar (standard target):                Goals.               (line 100)
  10324. * shell command:                         Simple Makefile.     (line  72)
  10325. * shell command, and directory search:   Commands/Search.     (line   6)
  10326. * shell command, execution:              Execution.           (line   6)
  10327. * shell command, function for:           Shell Function.      (line   6)
  10328. * shell file name pattern (in include):  Include.             (line  12)
  10329. * shell wildcards (in include):          Include.             (line  12)
  10330. * SHELL, MS-DOS specifics:               Execution.           (line  36)
  10331. * signal:                                Interrupts.          (line   6)
  10332. * silent operation:                      Echoing.             (line   6)
  10333. * simple makefile:                       Simple Makefile.     (line   6)
  10334. * simple variable expansion:             Using Variables.     (line   6)
  10335. * simplifying with variables:            Variables Simplify.  (line   6)
  10336. * simply expanded variables:             Flavors.             (line  56)
  10337. * sorting words:                         Text Functions.      (line 146)
  10338. * spaces, in variable values:            Flavors.             (line 104)
  10339. * spaces, stripping:                     Text Functions.      (line  80)
  10340. * special targets:                       Special Targets.     (line   6)
  10341. * special variables:                     Special Variables.   (line   6)
  10342. * specifying makefile name:              Makefile Names.      (line  30)
  10343. * standard input:                        Parallel.            (line  30)
  10344. * standards conformance:                 Overview.            (line  13)
  10345. * standards for makefiles:               Makefile Conventions.
  10346.                                                               (line   6)
  10347. * static pattern rule:                   Static Pattern.      (line   6)
  10348. * static pattern rule, syntax of:        Static Usage.        (line   6)
  10349. * static pattern rule, versus implicit:  Static versus Implicit.
  10350.                                                               (line   6)
  10351. * stem <1>:                              Pattern Match.       (line   6)
  10352. * stem:                                  Static Usage.        (line  17)
  10353. * stem, variable for:                    Automatic.           (line  61)
  10354. * stopping make:                         Make Control Functions.
  10355.                                                               (line  11)
  10356. * strings, searching for:                Text Functions.      (line 103)
  10357. * stripping whitespace:                  Text Functions.      (line  80)
  10358. * sub-make:                              Variables/Recursion. (line   6)
  10359. * subdirectories, recursion for:         Recursion.           (line   6)
  10360. * substitution variable reference:       Substitution Refs.   (line   6)
  10361. * suffix rule:                           Suffix Rules.        (line   6)
  10362. * suffix rule, for archive:              Archive Suffix Rules.
  10363.                                                               (line   6)
  10364. * suffix, adding:                        File Name Functions. (line  68)
  10365. * suffix, function to find:              File Name Functions. (line  43)
  10366. * suffix, substituting in variables:     Substitution Refs.   (line   6)
  10367. * switches:                              Options Summary.     (line   6)
  10368. * symbol directories, updating archive:  Archive Symbols.     (line   6)
  10369. * syntax of rules:                       Rule Syntax.         (line   6)
  10370. * tab character (in commands):           Rule Syntax.         (line  26)
  10371. * tabs in rules:                         Rule Introduction.   (line  21)
  10372. * TAGS (standard target):                Goals.               (line 108)
  10373. * tangle <1>:                            Implicit Variables.  (line  92)
  10374. * tangle:                                Catalogue of Rules.  (line 144)
  10375. * tar (standard target):                 Goals.               (line  97)
  10376. * target:                                Rules.               (line   6)
  10377. * target pattern, implicit:              Pattern Intro.       (line   9)
  10378. * target pattern, static (not implicit): Static Usage.        (line  17)
  10379. * target, deleting on error:             Errors.              (line  64)
  10380. * target, deleting on interrupt:         Interrupts.          (line   6)
  10381. * target, expansion:                     Reading Makefiles.   (line  58)
  10382. * target, multiple in pattern rule:      Pattern Intro.       (line  48)
  10383. * target, multiple rules for one:        Multiple Rules.      (line   6)
  10384. * target, touching:                      Instead of Execution.
  10385.                                                               (line  19)
  10386. * target-specific variables:             Target-specific.     (line   6)
  10387. * targets:                               Rule Syntax.         (line  18)
  10388. * targets without a file:                Phony Targets.       (line   6)
  10389. * targets, built-in special:             Special Targets.     (line   6)
  10390. * targets, empty:                        Empty Targets.       (line   6)
  10391. * targets, force:                        Force Targets.       (line   6)
  10392. * targets, introduction to:              Rule Introduction.   (line   8)
  10393. * targets, multiple:                     Multiple Targets.    (line   6)
  10394. * targets, phony:                        Phony Targets.       (line   6)
  10395. * terminal rule:                         Match-Anything Rules.
  10396.                                                               (line   6)
  10397. * test (standard target):                Goals.               (line 112)
  10398. * testing compilation:                   Testing.             (line   6)
  10399. * tex <1>:                               Implicit Variables.  (line  79)
  10400. * tex:                                   Catalogue of Rules.  (line 144)
  10401. * TeX, rule to run:                      Catalogue of Rules.  (line 144)
  10402. * texi2dvi <1>:                          Implicit Variables.  (line  83)
  10403. * texi2dvi:                              Catalogue of Rules.  (line 151)
  10404. * Texinfo, rule to format:               Catalogue of Rules.  (line 151)
  10405. * tilde (~):                             Wildcards.           (line  11)
  10406. * touch (shell command) <1>:             Empty Targets.       (line  25)
  10407. * touch (shell command):                 Wildcard Examples.   (line  21)
  10408. * touching files:                        Instead of Execution.
  10409.                                                               (line  19)
  10410. * traditional directory search (GPATH):  Search Algorithm.    (line  42)
  10411. * types of prerequisites:                Prerequisite Types.  (line   6)
  10412. * undefined variables, warning message:  Options Summary.     (line 238)
  10413. * updating archive symbol directories:   Archive Symbols.     (line   6)
  10414. * updating makefiles:                    Remaking Makefiles.  (line   6)
  10415. * user defined functions:                Call Function.       (line   6)
  10416. * value:                                 Using Variables.     (line   6)
  10417. * value, how a variable gets it:         Values.              (line   6)
  10418. * variable:                              Using Variables.     (line   6)
  10419. * variable definition:                   Makefile Contents.   (line  22)
  10420. * variables:                             Variables Simplify.  (line   6)
  10421. * variables, $ in name:                  Computed Names.      (line   6)
  10422. * variables, and implicit rule:          Automatic.           (line   6)
  10423. * variables, appending to:               Appending.           (line   6)
  10424. * variables, automatic:                  Automatic.           (line   6)
  10425. * variables, command line:               Overriding.          (line   6)
  10426. * variables, command line, and recursion: Options/Recursion.  (line  17)
  10427. * variables, computed names:             Computed Names.      (line   6)
  10428. * variables, conditional assignment:     Flavors.             (line 130)
  10429. * variables, defining verbatim:          Defining.            (line   6)
  10430. * variables, environment <1>:            Environment.         (line   6)
  10431. * variables, environment:                Variables/Recursion. (line   6)
  10432. * variables, exporting:                  Variables/Recursion. (line   6)
  10433. * variables, flavors:                    Flavors.             (line   6)
  10434. * variables, how they get their values:  Values.              (line   6)
  10435. * variables, how to reference:           Reference.           (line   6)
  10436. * variables, loops in expansion:         Flavors.             (line  44)
  10437. * variables, modified reference:         Substitution Refs.   (line   6)
  10438. * variables, nested references:          Computed Names.      (line   6)
  10439. * variables, origin of:                  Origin Function.     (line   6)
  10440. * variables, overriding:                 Override Directive.  (line   6)
  10441. * variables, overriding with arguments:  Overriding.          (line   6)
  10442. * variables, pattern-specific:           Pattern-specific.    (line   6)
  10443. * variables, recursively expanded:       Flavors.             (line   6)
  10444. * variables, setting:                    Setting.             (line   6)
  10445. * variables, simply expanded:            Flavors.             (line  56)
  10446. * variables, spaces in values:           Flavors.             (line 104)
  10447. * variables, substituting suffix in:     Substitution Refs.   (line   6)
  10448. * variables, substitution reference:     Substitution Refs.   (line   6)
  10449. * variables, target-specific:            Target-specific.     (line   6)
  10450. * variables, unexpanded value:           Value Function.      (line   6)
  10451. * variables, warning for undefined:      Options Summary.     (line 238)
  10452. * varying prerequisites:                 Static Pattern.      (line   6)
  10453. * verbatim variable definition:          Defining.            (line   6)
  10454. * vpath:                                 Directory Search.    (line   6)
  10455. * VPATH, and implicit rules:             Implicit/Search.     (line   6)
  10456. * VPATH, and link libraries:             Libraries/Search.    (line   6)
  10457. * warnings, printing:                    Make Control Functions.
  10458.                                                               (line  35)
  10459. * weave <1>:                             Implicit Variables.  (line  86)
  10460. * weave:                                 Catalogue of Rules.  (line 144)
  10461. * Web, rule to run:                      Catalogue of Rules.  (line 144)
  10462. * what if:                               Instead of Execution.
  10463.                                                               (line  33)
  10464. * whitespace, in variable values:        Flavors.             (line 104)
  10465. * whitespace, stripping:                 Text Functions.      (line  80)
  10466. * wildcard:                              Wildcards.           (line   6)
  10467. * wildcard pitfalls:                     Wildcard Pitfall.    (line   6)
  10468. * wildcard, function:                    File Name Functions. (line 107)
  10469. * wildcard, in archive member:           Archive Members.     (line  36)
  10470. * wildcard, in include:                  Include.             (line  12)
  10471. * wildcards and MS-DOS/MS-Windows backslashes: Wildcard Pitfall.
  10472.                                                               (line  31)
  10473. * word, selecting a:                     Text Functions.      (line 159)
  10474. * words, extracting first:               Text Functions.      (line 184)
  10475. * words, filtering:                      Text Functions.      (line 114)
  10476. * words, filtering out:                  Text Functions.      (line 132)
  10477. * words, finding number:                 Text Functions.      (line 180)
  10478. * words, iterating over:                 Foreach Function.    (line   6)
  10479. * words, joining lists:                  File Name Functions. (line  90)
  10480. * words, removing duplicates:            Text Functions.      (line 155)
  10481. * words, selecting lists of:             Text Functions.      (line 168)
  10482. * writing rule commands:                 Commands.            (line   6)
  10483. * writing rules:                         Rules.               (line   6)
  10484. * yacc <1>:                              Implicit Variables.  (line  68)
  10485. * yacc <2>:                              Catalogue of Rules.  (line 113)
  10486. * yacc:                                  Sequences.           (line  18)
  10487. * Yacc, rule to run:                     Catalogue of Rules.  (line 113)
  10488. * ~ (tilde):                             Wildcards.           (line  11)
  10489.  
  10490. 
  10491. File: make,  Node: Name Index,  Prev: Concept Index,  Up: Top
  10492.  
  10493. Index of Functions, Variables, & Directives
  10494. *******************************************
  10495.  
  10496. [index]
  10497. * Menu:
  10498.  
  10499. * $$(@D):                                Automatic.           (line 151)
  10500. * $$(@F):                                Automatic.           (line 151)
  10501. * $$@:                                   Automatic.           (line 151)
  10502. * $%:                                    Automatic.           (line  26)
  10503. * $(%D):                                 Automatic.           (line 113)
  10504. * $(%F):                                 Automatic.           (line 114)
  10505. * $(*D):                                 Automatic.           (line 108)
  10506. * $(*F):                                 Automatic.           (line 109)
  10507. * $(+D):                                 Automatic.           (line 131)
  10508. * $(+F):                                 Automatic.           (line 132)
  10509. * $(.VARIABLES):                         Special Variables.   (line  10)
  10510. * $(<D):                                 Automatic.           (line 121)
  10511. * $(<F):                                 Automatic.           (line 122)
  10512. * $(?D):                                 Automatic.           (line 137)
  10513. * $(?F):                                 Automatic.           (line 138)
  10514. * $(@D):                                 Automatic.           (line  97)
  10515. * $(@F):                                 Automatic.           (line 103)
  10516. * $(^D):                                 Automatic.           (line 126)
  10517. * $(^F):                                 Automatic.           (line 127)
  10518. * $*:                                    Automatic.           (line  57)
  10519. * $*, and static pattern:                Static Usage.        (line  81)
  10520. * $+:                                    Automatic.           (line  51)
  10521. * $<:                                    Automatic.           (line  32)
  10522. * $?:                                    Automatic.           (line  37)
  10523. * $@:                                    Automatic.           (line  19)
  10524. * $^:                                    Automatic.           (line  42)
  10525. * % (automatic variable):                Automatic.           (line  26)
  10526. * %D (automatic variable):               Automatic.           (line 113)
  10527. * %F (automatic variable):               Automatic.           (line 114)
  10528. * * (automatic variable):                Automatic.           (line  57)
  10529. * * (automatic variable), unsupported bizarre usage: Missing. (line  44)
  10530. * *D (automatic variable):               Automatic.           (line 108)
  10531. * *F (automatic variable):               Automatic.           (line 109)
  10532. * + (automatic variable):                Automatic.           (line  51)
  10533. * +D (automatic variable):               Automatic.           (line 131)
  10534. * +F (automatic variable):               Automatic.           (line 132)
  10535. * .DEFAULT <1>:                          Last Resort.         (line  23)
  10536. * .DEFAULT:                              Special Targets.     (line  20)
  10537. * .DEFAULT, and empty commands:          Empty Commands.      (line  16)
  10538. * .DELETE_ON_ERROR <1>:                  Errors.              (line  64)
  10539. * .DELETE_ON_ERROR:                      Special Targets.     (line  57)
  10540. * .EXPORT_ALL_VARIABLES <1>:             Variables/Recursion. (line  94)
  10541. * .EXPORT_ALL_VARIABLES:                 Special Targets.     (line 119)
  10542. * .IGNORE <1>:                           Errors.              (line  30)
  10543. * .IGNORE:                               Special Targets.     (line  64)
  10544. * .INTERMEDIATE:                         Special Targets.     (line  43)
  10545. * .LIBPATTERNS:                          Libraries/Search.    (line   6)
  10546. * .LOW_RESOLUTION_TIME:                  Special Targets.     (line  76)
  10547. * .NOTPARALLEL:                          Special Targets.     (line 124)
  10548. * .PHONY <1>:                            Special Targets.     (line   8)
  10549. * .PHONY:                                Phony Targets.       (line  22)
  10550. * .POSIX:                                Options/Recursion.   (line  60)
  10551. * .PRECIOUS <1>:                         Interrupts.          (line  22)
  10552. * .PRECIOUS:                             Special Targets.     (line  28)
  10553. * .SECONDARY:                            Special Targets.     (line  48)
  10554. * .SILENT <1>:                           Echoing.             (line  24)
  10555. * .SILENT:                               Special Targets.     (line 106)
  10556. * .SUFFIXES <1>:                         Suffix Rules.        (line  61)
  10557. * .SUFFIXES:                             Special Targets.     (line  15)
  10558. * .VARIABLES (list of variables):        Special Variables.   (line  10)
  10559. * /usr/gnu/include:                      Include.             (line  51)
  10560. * /usr/include:                          Include.             (line  51)
  10561. * /usr/local/include:                    Include.             (line  51)
  10562. * < (automatic variable):                Automatic.           (line  32)
  10563. * <D (automatic variable):               Automatic.           (line 121)
  10564. * <F (automatic variable):               Automatic.           (line 122)
  10565. * ? (automatic variable):                Automatic.           (line  37)
  10566. * ?D (automatic variable):               Automatic.           (line 137)
  10567. * ?F (automatic variable):               Automatic.           (line 138)
  10568. * @ (automatic variable):                Automatic.           (line  19)
  10569. * @D (automatic variable):               Automatic.           (line  97)
  10570. * @F (automatic variable):               Automatic.           (line 103)
  10571. * ^ (automatic variable):                Automatic.           (line  42)
  10572. * ^D (automatic variable):               Automatic.           (line 126)
  10573. * ^F (automatic variable):               Automatic.           (line 127)
  10574. * addprefix:                             File Name Functions. (line  79)
  10575. * addsuffix:                             File Name Functions. (line  68)
  10576. * AR:                                    Implicit Variables.  (line  34)
  10577. * ARFLAGS:                               Implicit Variables.  (line 105)
  10578. * AS:                                    Implicit Variables.  (line  37)
  10579. * ASFLAGS:                               Implicit Variables.  (line 108)
  10580. * basename:                              File Name Functions. (line  57)
  10581. * bindir:                                Directory Variables. (line  45)
  10582. * call:                                  Call Function.       (line   6)
  10583. * CC:                                    Implicit Variables.  (line  40)
  10584. * CFLAGS:                                Implicit Variables.  (line 112)
  10585. * CO:                                    Implicit Variables.  (line  46)
  10586. * COFLAGS:                               Implicit Variables.  (line 118)
  10587. * COMSPEC:                               Execution.           (line  33)
  10588. * CPP:                                   Implicit Variables.  (line  49)
  10589. * CPPFLAGS:                              Implicit Variables.  (line 121)
  10590. * CTANGLE:                               Implicit Variables.  (line  95)
  10591. * CWEAVE:                                Implicit Variables.  (line  89)
  10592. * CXX:                                   Implicit Variables.  (line  43)
  10593. * CXXFLAGS:                              Implicit Variables.  (line 115)
  10594. * define:                                Defining.            (line   6)
  10595. * dir:                                   File Name Functions. (line  17)
  10596. * else:                                  Conditional Syntax.  (line   6)
  10597. * endef:                                 Defining.            (line   6)
  10598. * endif:                                 Conditional Syntax.  (line   6)
  10599. * error:                                 Make Control Functions.
  10600.                                                               (line  11)
  10601. * eval:                                  Eval Function.       (line   6)
  10602. * exec_prefix:                           Directory Variables. (line  27)
  10603. * export:                                Variables/Recursion. (line  35)
  10604. * FC:                                    Implicit Variables.  (line  53)
  10605. * FFLAGS:                                Implicit Variables.  (line 125)
  10606. * filter:                                Text Functions.      (line 114)
  10607. * filter-out:                            Text Functions.      (line 132)
  10608. * findstring:                            Text Functions.      (line 103)
  10609. * firstword:                             Text Functions.      (line 184)
  10610. * foreach:                               Foreach Function.    (line   6)
  10611. * GET:                                   Implicit Variables.  (line  57)
  10612. * GFLAGS:                                Implicit Variables.  (line 128)
  10613. * GNUmakefile:                           Makefile Names.      (line   7)
  10614. * GPATH:                                 Search Algorithm.    (line  48)
  10615. * if:                                    If Function.         (line   6)
  10616. * ifdef:                                 Conditional Syntax.  (line   6)
  10617. * ifeq:                                  Conditional Syntax.  (line   6)
  10618. * ifndef:                                Conditional Syntax.  (line   6)
  10619. * ifneq:                                 Conditional Syntax.  (line   6)
  10620. * include:                               Include.             (line   6)
  10621. * join:                                  File Name Functions. (line  90)
  10622. * LDFLAGS:                               Implicit Variables.  (line 131)
  10623. * LEX:                                   Implicit Variables.  (line  60)
  10624. * LFLAGS:                                Implicit Variables.  (line 135)
  10625. * libexecdir:                            Directory Variables. (line  58)
  10626. * MAKE <1>:                              Flavors.             (line  84)
  10627. * MAKE:                                  MAKE Variable.       (line   6)
  10628. * MAKECMDGOALS:                          Goals.               (line  27)
  10629. * makefile:                              Makefile Names.      (line   7)
  10630. * Makefile:                              Makefile Names.      (line   7)
  10631. * MAKEFILES <1>:                         Variables/Recursion. (line 122)
  10632. * MAKEFILES:                             MAKEFILES Variable.  (line   6)
  10633. * MAKEFLAGS:                             Options/Recursion.   (line   6)
  10634. * MAKEINFO:                              Implicit Variables.  (line  75)
  10635. * MAKELEVEL <1>:                         Flavors.             (line  84)
  10636. * MAKELEVEL:                             Variables/Recursion. (line 110)
  10637. * MAKEOVERRIDES:                         Options/Recursion.   (line  49)
  10638. * MFLAGS:                                Options/Recursion.   (line  65)
  10639. * notdir:                                File Name Functions. (line  27)
  10640. * origin:                                Origin Function.     (line   6)
  10641. * OUTPUT_OPTION:                         Catalogue of Rules.  (line 195)
  10642. * override:                              Override Directive.  (line   6)
  10643. * patsubst <1>:                          Text Functions.      (line  18)
  10644. * patsubst:                              Substitution Refs.   (line  28)
  10645. * PC:                                    Implicit Variables.  (line  64)
  10646. * PFLAGS:                                Implicit Variables.  (line 138)
  10647. * prefix:                                Directory Variables. (line  17)
  10648. * RFLAGS:                                Implicit Variables.  (line 141)
  10649. * RM:                                    Implicit Variables.  (line  98)
  10650. * sbindir:                               Directory Variables. (line  51)
  10651. * shell:                                 Shell Function.      (line   6)
  10652. * SHELL:                                 Execution.           (line  30)
  10653. * SHELL (command execution):             Execution.           (line   6)
  10654. * sort:                                  Text Functions.      (line 146)
  10655. * strip:                                 Text Functions.      (line  80)
  10656. * subst <1>:                             Text Functions.      (line   9)
  10657. * subst:                                 Multiple Targets.    (line  28)
  10658. * suffix:                                File Name Functions. (line  43)
  10659. * SUFFIXES:                              Suffix Rules.        (line  81)
  10660. * TANGLE:                                Implicit Variables.  (line  92)
  10661. * TEX:                                   Implicit Variables.  (line  79)
  10662. * TEXI2DVI:                              Implicit Variables.  (line  82)
  10663. * unexport:                              Variables/Recursion. (line  40)
  10664. * value:                                 Value Function.      (line   6)
  10665. * vpath:                                 Selective Search.    (line   6)
  10666. * VPATH:                                 General Search.      (line   6)
  10667. * vpath:                                 Directory Search.    (line   6)
  10668. * VPATH:                                 Directory Search.    (line   6)
  10669. * warning:                               Make Control Functions.
  10670.                                                               (line  35)
  10671. * WEAVE:                                 Implicit Variables.  (line  86)
  10672. * wildcard <1>:                          File Name Functions. (line 107)
  10673. * wildcard:                              Wildcard Function.   (line   6)
  10674. * word:                                  Text Functions.      (line 159)
  10675. * wordlist:                              Text Functions.      (line 168)
  10676. * words:                                 Text Functions.      (line 180)
  10677. * YACC:                                  Implicit Variables.  (line  67)
  10678. * YACCR:                                 Implicit Variables.  (line  71)
  10679. * YFLAGS:                                Implicit Variables.  (line 144)
  10680.  
  10681.  
  10682. 
  10683. Tag Table:
  10684. Node: Top1032
  10685. Node: Overview13562
  10686. Node: Preparing14564
  10687. Node: Reading15531
  10688. Node: Bugs16453
  10689. Node: Introduction18278
  10690. Node: Rule Introduction19865
  10691. Node: Simple Makefile21604
  10692. Node: How Make Works25229
  10693. Node: Variables Simplify27724
  10694. Node: make Deduces29925
  10695. Node: Combine By Prerequisite31660
  10696. Node: Cleanup32684
  10697. Node: Makefiles34098
  10698. Node: Makefile Contents34980
  10699. Node: Makefile Names37927
  10700. Node: Include39533
  10701. Ref: Include-Footnote-143091
  10702. Node: MAKEFILES Variable43225
  10703. Node: MAKEFILE_LIST Variable44730
  10704. Node: Special Variables46037
  10705. Node: Remaking Makefiles46775
  10706. Node: Overriding Makefiles51019
  10707. Node: Reading Makefiles53067
  10708. Node: Rules55592
  10709. Node: Rule Example58259
  10710. Node: Rule Syntax59111
  10711. Node: Prerequisite Types61335
  10712. Node: Wildcards63115
  10713. Node: Wildcard Examples64801
  10714. Node: Wildcard Pitfall66061
  10715. Node: Wildcard Function67845
  10716. Node: Directory Search69624
  10717. Node: General Search70761
  10718. Node: Selective Search72500
  10719. Node: Search Algorithm75483
  10720. Node: Commands/Search77997
  10721. Node: Implicit/Search79348
  10722. Node: Libraries/Search80287
  10723. Node: Phony Targets82376
  10724. Node: Force Targets87303
  10725. Node: Empty Targets88343
  10726. Node: Special Targets89646
  10727. Node: Multiple Targets96345
  10728. Node: Multiple Rules98225
  10729. Node: Static Pattern100456
  10730. Node: Static Usage101103
  10731. Node: Static versus Implicit104828
  10732. Node: Double-Colon106567
  10733. Node: Automatic Prerequisites108219
  10734. Node: Commands112463
  10735. Node: Echoing114151
  10736. Node: Execution115432
  10737. Ref: Execution-Footnote-1119861
  10738. Node: Parallel120007
  10739. Node: Errors123595
  10740. Node: Interrupts127236
  10741. Node: Recursion128818
  10742. Node: MAKE Variable130720
  10743. Node: Variables/Recursion132710
  10744. Node: Options/Recursion137864
  10745. Node: -w Option143024
  10746. Node: Sequences144014
  10747. Node: Empty Commands147021
  10748. Node: Using Variables148190
  10749. Node: Reference151307
  10750. Node: Flavors152871
  10751. Node: Advanced158655
  10752. Node: Substitution Refs159155
  10753. Node: Computed Names160703
  10754. Node: Values165242
  10755. Node: Setting166159
  10756. Node: Appending168200
  10757. Node: Override Directive172117
  10758. Node: Defining173496
  10759. Node: Environment175955
  10760. Node: Target-specific178230
  10761. Node: Pattern-specific180631
  10762. Node: Conditionals181828
  10763. Node: Conditional Example182533
  10764. Node: Conditional Syntax185105
  10765. Node: Testing Flags189986
  10766. Node: Functions191083
  10767. Node: Syntax of Functions192424
  10768. Node: Text Functions194618
  10769. Node: File Name Functions202771
  10770. Node: Foreach Function207213
  10771. Node: If Function210416
  10772. Node: Call Function211687
  10773. Node: Value Function214562
  10774. Node: Eval Function215994
  10775. Node: Origin Function218262
  10776. Node: Shell Function221484
  10777. Node: Make Control Functions223133
  10778. Node: Running224558
  10779. Node: Makefile Arguments226542
  10780. Node: Goals227253
  10781. Node: Instead of Execution231806
  10782. Node: Avoiding Compilation235087
  10783. Node: Overriding237057
  10784. Node: Testing239350
  10785. Node: Options Summary241230
  10786. Node: Implicit Rules250664
  10787. Node: Using Implicit252809
  10788. Node: Catalogue of Rules256343
  10789. Node: Implicit Variables265331
  10790. Node: Chained Rules269598
  10791. Node: Pattern Rules273604
  10792. Node: Pattern Intro275135
  10793. Node: Pattern Examples278000
  10794. Node: Automatic279804
  10795. Node: Pattern Match287479
  10796. Node: Match-Anything Rules289099
  10797. Node: Canceling Rules292969
  10798. Node: Last Resort293680
  10799. Node: Suffix Rules295522
  10800. Node: Implicit Rule Search299246
  10801. Node: Archives302769
  10802. Node: Archive Members303462
  10803. Node: Archive Update305063
  10804. Node: Archive Symbols306981
  10805. Node: Archive Pitfalls308210
  10806. Node: Archive Suffix Rules308928
  10807. Node: Features310470
  10808. Node: Missing319050
  10809. Node: Makefile Conventions322783
  10810. Node: Makefile Basics323564
  10811. Node: Utilities in Makefiles326726
  10812. Node: Command Variables328859
  10813. Node: Directory Variables332424
  10814. Node: Standard Targets343306
  10815. Ref: Standard Targets-Footnote-1354545
  10816. Node: Install Command Categories354645
  10817. Node: Quick Reference359215
  10818. Node: Error Messages368667
  10819. Node: Complex Makefile376353
  10820. Node: GNU Free Documentation License384910
  10821. Node: Concept Index404823
  10822. Node: Name Index466596
  10823. 
  10824. End Tag Table
  10825.